Image encoding/decoding method and apparatus with sub-block intra prediction

ABSTRACT

An image encoding/decoding method and apparatus for performing intra prediction are provided. An image decoding method of the present invention comprises deriving an intra prediction mode for a current block, selecting at least one reconstructed sample line neighboring to the current block, constructing a reference sample using at least one reconstructed sample included in the at least one reconstructed sample line, and performing intra prediction for the current block based on the intra prediction mode and the reference sample.

CROSS REFERENCE TO RELATED APPLICATION(S)

This application is a Continuation Application of U.S. patentapplication Ser. No. 17/591,830, filed on Feb. 3, 2022, which is aContinuation Application of U.S. patent application Ser. No. 16/321,145,filed on Jan. 28, 2019, now U.S. Pat. No. 11,405,620, issues on Aug. 2,2022, which is a U.S. National Stage Application of InternationalApplication No. PCT/KR2017/008286, filed on Aug. 1, 2017, which claimsthe benefit under USC 119(a) and 365(b) of Korean Patent Application No.10-2016-0098095, filed on Aug. 1, 2016, in the Korean IntellectualProperty Office, the entire disclosures of which are incorporated hereinby reference for all purposes.

TECHNICAL FIELD

The present invention relates to a method and apparatus forencoding/decoding an image. Particularly, the present invention relatesto a method and apparatus for encoding/decoding an image using intraprediction and a recording medium storing a bitstream generated by animage encoding method/apparatus of the present invention.

BACKGROUND ART

Recently, demands for high-resolution and high-quality images such ashigh definition (HD) images and ultra high definition (UHD) images, haveincreased in various application fields. However, higher resolution andquality image data has increasing amounts of data in comparison withconventional image data. Therefore, when transmitting image data byusing a medium such as conventional wired and wireless broadbandnetworks, or when storing image data by using a conventional storagemedium, costs of transmitting and storing increase. In order to solvethese problems occurring with an increase in resolution and quality ofimage data, high-efficiency image encoding/decoding techniques arerequired for higher-resolution and higher-quality images.

Image compression technology includes various techniques, including: aninter-prediction technique of predicting a pixel value included in acurrent picture from a previous or subsequent picture of the currentpicture; an intra-prediction technique of predicting a pixel valueincluded in a current picture by using pixel information in the currentpicture; a transform and quantization technique for compressing energyof a residual signal; an entropy encoding technique of assigning a shortcode to a value with a high appearance frequency and assigning a longcode to a value with a low appearance frequency; etc. Image data may beeffectively compressed by using such image compression technology, andmay be transmitted or stored.

DISCLOSURE Technical Problem

An object of the present invention is to provide a method and apparatusfor encoding and decoding an image to enhance compression efficiency.

Another object of the present invention is to provide a method andapparatus for encoding and decoding an image using intra prediction toenhance compression efficiency.

Another object of the present invention is to provide a recording mediumstoring a bitstream generated by an image encoding method/apparatus ofthe present invention.

Technical Solution

An image decoding method according to the present invention may comprisederiving an intra prediction mode for a current block, selecting atleast one reconstructed sample line neighboring to the current block,constructing a reference sample using at least one reconstructed sampleincluded in the at least one reconstructed sample line, and performingintra prediction for the current block based on the intra predictionmode and the reference sample.

In the image decoding method of the present invention, the at least onereconstructed sample line may include at least one of neighborreconstructed sample lines adjacent to an upper side and a left side ofthe current block.

In the image decoding method of the present invention, the number of theneighbor reconstructed sample lines adjacent to the upper side and theleft side may be determined based on at least one of a size, a shape,and an intra prediction mode of the current block.

In the image decoding method of the present invention, the referencesample may be derived using a weighted sum of the at least onereconstructed sample.

In the image decoding method of the present invention, the weighted summay be performed based on at least one of the intra prediction mode anda distance between the current block and the reconstructed sample line.

In the image decoding method of the present invention, the constructionof a reference sample may further comprise searching a reconstructedsample similar to the current block from among reconstructed samplesincluded in at least one of a top row and a left column neighboring tothe current block, and replacing at least one reconstructed sampleincluded in the reconstructed sample line with the searchedreconstructed sample.

The image decoding method of the present invention may further comprisedividing the current block into a plurality of sub-blocks, and intraprediction may be performed for each of the plurality of sub-blocksbased on a reference sample constructed on the basis of the currentblock.

In the image decoding method of the present invention, when intraprediction is performed for one of the plurality of sub-blocks using thereference sample constructed on the basis of the current block, theintra prediction may be performed after compensating a reference samplewhich is not neighboring to the one sub-block.

In the image decoding method of the present invention, the performing ofintra prediction may comprise predicting at least one sample amongsamples included in a right column, samples included in a bottom row,and a bottom right sample within the current block, using the at leastone reconstructed sample, and predicting remaining samples within thecurrent block, using the at least one predicted sample.

An image decoding apparatus according to the present invention maycomprise an intra predictor which is configured to derive an intraprediction mode for a current block, to select at least onereconstructed sample line neighboring to the current block, to constructa reference sample using at least one reconstructed sample included inthe at least one reconstructed sample line, and to perform intraprediction for the current block based on the intra prediction mode andthe reference sample.

An image encoding apparatus according to the present invention maycomprise determining an intra prediction mode for a current block,selecting at least one reconstructed sample line neighboring to thecurrent block, constructing a reference sample using at least onereconstructed sample included in the at least one reconstructed sampleline, and performing intra prediction for the current block based on theintra prediction mode and the reference sample.

In the image encoding method of the present invention, the at least onereconstructed sample line may include at least one among reconstructedsample lines adjacent to an upper side and a left side of the currentblock.

In the image encoding method of the present invention, the number of theneighbor reconstructed sample lines adjacent to the upper side and theleft side may be determined based on at least one of a size, a shape,and an intra prediction mode of the current block.

In the image encoding method of the present invention, the referencesample may be derived using a weighted sum of the at least onereconstructed sample.

In the image encoding method of the present invention, the weighted summay be performed based on at least one of the intra prediction mode anda distance between the current block and the reconstructed sample line.

In the image encoding method of the present invention, the constructionof a reference sample may comprise searching a reconstructed samplesimilar to the current block from among reconstructed samples includedin at least one of an upper row and a left column neighboring to thecurrent block, and replacing at least one reconstructed sample includedin the reconstructed sample line with the searched reconstructed sample.

The image encoding method of the present invention may further comprisedividing the current block into a plurality of sub-blocks, and intraprediction may be performed for each of the plurality of sub-blocksbased on a reference sample constructed on the basis of the currentblock.

In the image encoding method of the present invention, when intraprediction is performed for one of the plurality of sub-blocks using thereference sample constructed on the basis of the current block, theintra prediction may be performed after compensating a reference samplewhich is not neighboring to the one sub-block.

An image encoding apparatus according to the present invention maycomprises an intra predictor which is configured to determine an intraprediction mode for a current block, to select at least onereconstructed sample line neighboring to the current block, to constructa reference sample using at least one reconstructed sample included inthe at least one reconstructed sample line, and to perform intraprediction for the current block based on the intra prediction mode andthe reference sample.

A recording medium according to the present invention may store abitstream generated by an image encoding method, and the method maycomprise determining an intra prediction mode for a current block,selecting at least one reconstructed sample line neighboring to thecurrent block, constructing a reference sample using at least onereconstructed sample included in the at least one reconstructed sampleline, and performing intra prediction for the current block based on theintra prediction mode and the reference sample.

Advantageous Effects

According to the present invention, a method and apparatus for encodingand decoding an image to enhance compression efficiency may be provided.

According to the present invention, a method and apparatus for encodingand decoding an image using intra prediction to enhance compressionefficiency may be provided.

According to the present invention, a recording medium storing abitstream generated by an image encoding method/apparatus of the presentinvention may be provided.

DESCRIPTION OF DRAWINGS

FIG. 1 is a block diagram showing configurations of an encodingapparatus according to an embodiment of the present invention.

FIG. 2 is a block diagram showing configurations of a decoding apparatusaccording to an embodiment of the present invention.

FIG. 3 is a view schematically showing a partition structure of an imagewhen encoding and decoding the image.

FIG. 4 is a view showing forms of a prediction unit (PU) that may beincluded in a coding unit (CU).

FIG. 5 is a view showing forms of a transform unit (TU) that may beincluded in a coding unit (CU).

FIG. 6 is a view for explaining an embodiment of a process of intraprediction.

FIG. 7 is a view depicting a method for performing intra prediction on acurrent block according to an embodiment of the present invention.

FIG. 8 is a view depicting a method for deriving an intra predictionmode of a current block from a neighbor block.

FIG. 9 is an exemplary view depicting neighbor reconstructed samplelines which may be used for intra prediction of a current block.

FIG. 10 is a view depicting an embodiment of reconstructing referencesamples.

FIG. 11 is a view depicting another embodiment of reconstructingreference samples.

FIG. 12 is a view depicting another embodiment of reconstructingreference samples.

FIG. 13 is a view depicting an embodiment of encoding/decoding aplurality of prediction blocks generated by dividing a current block.

FIG. 14 is a view depicting another embodiment of encoding/decoding aplurality of prediction blocks generated by dividing a current block.

FIG. 15 is a view depicting a method for replacing an unavailablereconstructed sample, using an available reconstructed sample.

FIG. 16 is a view depicting another method for replacing unavailablereconstructed samples, using available reconstructed samples.

FIG. 17 is an exemplary view depicting padding of reference samples inthe case where one or more reconstructed sample lines are used.

FIG. 18 is a view depicting filtering of reference samples includingpadded unavailable reference samples.

FIG. 19 is a view depicting filtering of reference samples including anunavailable reference sample.

FIG. 20 is a view depicting an embodiment of generating a 1D referencesample array p_(1,ref) from P_(ref).

FIG. 21 is a view depicting intra prediction according to an embodimentof the present invention.

FIG. 22 is a view depicting intra prediction according to anotherembodiment of the present invention.

FIG. 23 is a view depicting intra prediction according to anotherembodiment of the present invention.

MODE FOR CARRYING OUT THE INVENTION

A variety of modifications may be made to the present invention andthere are various embodiments of the present invention, examples ofwhich will now be provided with reference to drawings and described indetail. However, the present invention is not limited thereto, althoughthe exemplary embodiments can be construed as including allmodifications, equivalents, or substitutes in a technical concept and atechnical scope of the present invention. The similar reference numeralsrefer to the same or similar functions in various aspects. In thedrawings, the shapes and dimensions of elements may be exaggerated forclarity. In the following detailed description of the present invention,references are made to the accompanying drawings that show, by way ofillustration, specific embodiments in which the invention may bepracticed. These embodiments are described in sufficient detail toenable those skilled in the art to implement the present disclosure. Itshould be understood that various embodiments of the present disclosure,although different, are not necessarily mutually exclusive. For example,specific features, structures, and characteristics described herein, inconnection with one embodiment, may be implemented within otherembodiments without departing from the spirit and scope of the presentdisclosure. In addition, it should be understood that the location orarrangement of individual elements within each disclosed embodiment maybe modified without departing from the spirit and scope of the presentdisclosure. The following detailed description is, therefore, not to betaken in a limiting sense, and the scope of the present disclosure isdefined only by the appended claims, appropriately interpreted, alongwith the full range of equivalents to what the claims claim.

Terms used in the specification, ‘first’, ‘second’, etc. can be used todescribe various components, but the components are not to be construedas being limited to the terms. The terms are only used to differentiateone component from other components. For example, the ‘first’ componentmay be named the ‘second’ component without departing from the scope ofthe present invention, and the ‘second’ component may also be similarlynamed the ‘first’ component. The term ‘and/or’ includes a combination ofa plurality of items or any one of a plurality of terms.

It will be understood that when an element is simply referred to asbeing ‘connected to’ or ‘coupled to’ another element without being‘directly connected to’ or ‘directly coupled to’ another element in thepresent description, it may be ‘directly connected to’ or ‘directlycoupled to’ another element or be connected to or coupled to anotherelement, having the other element intervening therebetween. In contrast,it should be understood that when an element is referred to as being“directly coupled” or “directly connected” to another element, there areno intervening elements present.

Furthermore, constitutional parts shown in the embodiments of thepresent invention are independently shown so as to representcharacteristic functions different from each other. Thus, it does notmean that each constitutional part is constituted in a constitutionalunit of separated hardware or software. In other words, eachconstitutional part includes each of enumerated constitutional parts forconvenience. Thus, at least two constitutional parts of eachconstitutional part may be combined to form one constitutional part orone constitutional part may be divided into a plurality ofconstitutional parts to perform each function. The embodiment where eachconstitutional part is combined and the embodiment where oneconstitutional part is divided are also included in the scope of thepresent invention, if not departing from the essence of the presentinvention.

The terms used in the present specification are merely used to describeparticular embodiments, and are not intended to limit the presentinvention. An expression used in the singular encompasses the expressionof the plural, unless it has a clearly different meaning in the context.In the present specification, it is to be understood that terms such as“including”, “having”, etc. are intended to indicate the existence ofthe features, numbers, steps, actions, elements, parts, or combinationsthereof disclosed in the specification, and are not intended to precludethe possibility that one or more other features, numbers, steps,actions, elements, parts, or combinations thereof may exist or may beadded. In other words, when a specific element is referred to as being“included”, elements other than the corresponding element are notexcluded, but additional elements may be included in embodiments of thepresent invention or the scope of the present invention.

In addition, some of constituents may not be indispensable constituentsperforming essential functions of the present invention but be selectiveconstituents improving only performance thereof. The present inventionmay be implemented by including only the indispensable constitutionalparts for implementing the essence of the present invention except theconstituents used in improving performance. The structure including onlythe indispensable constituents except the selective constituents used inimproving only performance is also included in the scope of the presentinvention.

Hereinafter, embodiments of the present invention will be described indetail with reference to the accompanying drawings. In describingexemplary embodiments of the present invention, well-known functions orconstructions will not be described in detail since they mayunnecessarily obscure the understanding of the present invention. Thesame constituent elements in the drawings are denoted by the samereference numerals, and a repeated description of the same elements willbe omitted.

In addition, hereinafter, an image may mean a picture configuring avideo, or may mean the video itself. For example, “encoding or decodingor both of an image” may mean “encoding or decoding or both of a video”,and may mean “encoding or decoding or both of one image among images ofa video.” Here, a picture and the image may have the same meaning.

Term Description

-   -   Encoder: may mean an apparatus performing encoding.    -   Decoder: may mean an apparatus performing decoding.    -   Parsing: may mean determination of a value of a syntax element        by performing entropy decoding, or may mean the entropy decoding        itself.    -   Block: may mean a sample of an M×N matrix. Here, M and N are        positive integers, and the block may mean a sample matrix in a        two-dimensional form.    -   Sample: is a basic unit of a block, and may indicate a value        ranging 0 to 2 Bd−1 depending on the bit depth (Bd). The sample        may mean a pixel in the present invention.    -   Unit: may mean a unit of encoding and decoding of an image. In        encoding and decoding an image, the unit may be an area        generated by partitioning one image. In addition, the unit may        mean a subdivided unit when one image is partitioned into        subdivided units during encoding or decoding. In encoding and        decoding an image, a predetermined process for each unit may be        performed. One unit may be partitioned into sub units that have        sizes smaller than the size of the unit. Depending on functions,        the unit may mean a block, a macroblock, a coding tree unit, a        coding tree block, a coding unit, a coding block, a prediction        unit, a prediction block, a transform unit, a transform block,        etc. In addition, in order to distinguish a unit from a block,        the unit may include a luma component block, a chroma component        block of the luma component block, and a syntax element of each        color component block. The unit may have various sizes and        shapes, and particularly, the shape of the unit may be a        two-dimensional geometrical figure such as a rectangular shape,        a square shape, a trapezoid shape, a triangular shape, a        pentagonal shape, etc. In addition, unit information may include        at least one of a unit type indicating the coding unit, the        prediction unit, the transform unit, etc., and a unit size, a        unit depth, a sequence of encoding and decoding of a unit, etc.    -   Reconstructed Neighbor Unit: may mean a reconstructed unit that        is previously spatially/temporally encoded or decoded, and the        reconstructed unit is adjacent to an encoding/decoding target        unit. Here, a reconstructed neighbor unit may mean a        reconstructed neighbor block.    -   Neighbor Block: may mean a block adjacent to an        encoding/decoding target block. The block adjacent to the        encoding/decoding target block may mean a block having a        boundary being in contact with the encoding/decoding target        block. The neighbor block may mean a block located at an        adjacent vertex of the encoding/decoding target block. The        neighbor block may mean a reconstructed neighbor block.    -   Unit Depth: may mean a partitioned degree of a unit. In a tree        structure, a root node may be the highest node, and a leaf node        may be the lowest node.    -   Symbol: may mean a syntax element of the encoding/decoding        target unit, a coding parameter, a value of a transform        coefficient, etc.    -   Parameter Set: may mean header information in a structure of the        bitstream. The parameter set may include at least one of a video        parameter set, a sequence parameter set, a picture parameter        set, or an adaptation parameter set. In addition, the parameter        set may mean slice header information and tile header        information, etc.    -   Bitstream: may mean a bit string including encoded image        information.    -   Transform Unit: may mean a basic unit when performing        encoding/decoding of a residual signal, similar to transform,        inverse transform, quantization, dequantization, and transform        coefficient encoding/decoding. One transform unit may be        partitioned into a plurality of small transform units. The        transform unit may have various sizes and shapes. Particularly,        the shape of the transform unit may be a two-dimensional        geometrical figure such as a rectangular shape, a square shape,        a trapezoid shape, a triangular shape, a pentagonal shape, etc.    -   Scaling: may mean a process of multiplying a factor to a        transform coefficient level, and as a result, a transform        coefficient may be generated. The scaling may be also referred        to as dequantization.    -   Quantization Parameter: may mean a value used in scaling the        transform coefficient level during quantization and        dequantization. Here, the quantization parameter may be a value        mapped to a step size of the quantization.    -   Delta Quantization Parameter: may mean a difference value        between a predicted quantization parameter and a quantization        parameter of the encoding/decoding target unit.    -   Scan: may mean a method of sorting coefficient orders within a        block or a matrix. For example, sorting a two-dimensional matrix        into a one-dimensional matrix may be referred to as scanning,        and sorting a one-dimensional matrix into a two-dimensional        matrix may be referred to as scanning or inverse scanning.    -   Transform Coefficient: may mean a coefficient value generated        after performing a transform. In the present invention, a        quantized transform coefficient level that is a transform        coefficient to which the quantization is applied may be referred        to as the transform coefficient.    -   Non-zero Transform Coefficient: may mean a transform coefficient        in which a value thereof is not 0, or may mean a transform        coefficient level in which a value thereof is not 0.    -   Quantization Matrix: may mean a matrix used in quantization and        dequantization in order to enhance subject quality or object        quality of an image. The quantization matrix may be referred to        as a scaling list.    -   Quantization Matrix Coefficient: may mean each element of a        quantization matrix. The quantization matrix coefficient may be        referred to as a matrix coefficient.    -   Default Matrix: may mean a predetermined quantization matrix        that is defined in the encoder and the decoder in advance.    -   Non-default Matrix: may mean a quantization matrix that is        transmitted/received by a user without being previously defined        in the encoder and the decoder.    -   Coding Tree Unit: may be composed of one luma component (Y)        coding tree unit and related two chroma components (Cb, Cr)        coding tree units. Each coding tree unit may be partitioned by        using at least one partition method such as a quad tree, a        binary tree, etc. to configure sub units such as coding units,        prediction units, transform units, etc. The coding tree unit may        be used as a term for indicating a pixel block that is a        processing unit in decoding/encoding process of an image, like        partition of an input image.    -   Coding Tree Block: may be used as a term for indicating one of        the Y coding tree unit, the Cb coding tree unit, and the Cr        coding tree unit.

FIG. 1 is a block diagram showing configurations of an encodingapparatus according to an embodiment of the present invention.

The encoding apparatus 100 may be a video encoding apparatus or an imageencoding apparatus. A video may include one or more images. The encodingapparatus 100 may encode the one or more images of the video in order oftime.

Referring to FIG. 1 , the encoding apparatus 100 may include a motionprediction unit 111, a motion compensation unit 112, an intra-predictionunit 120, a switch 115, a subtractor 125, a transform unit 130, aquantization unit 140, an entropy encoding unit 150, a dequantizationunit 160, an inverse transform unit 170, an adder 175, a filter unit180, and a reference picture buffer 190.

The encoding apparatus 100 may encode an input picture in an intra modeor an inter mode or both. In addition, the encoding apparatus 100 maygenerate a bitstream by encoding the input picture, and may output thegenerated bitstream. When the intra mode is used as a prediction mode,the switch 115 may be switched to intra. When the inter mode is used asa prediction mode, the switch 115 may be switched to inter. Here, theintra mode may be referred to as an intra-prediction mode, and the intermode may be referred to as an inter-prediction mode. The encodingapparatus 100 may generate a prediction block of an input block of theinput picture. In addition, after generating the prediction block, theencoding apparatus 100 may encode residuals between the input block andthe prediction block. The input picture may be referred to as a currentimage that is a target of current encoding. The input block may bereferred to as a current block or as an encoding target block that is atarget of the current encoding.

When the prediction mode is the intra mode, the intra-prediction unit120 may use a pixel value of a previously encoded block, which isadjacent to the current block, as a reference pixel. Theintra-prediction unit 120 may perform spatial prediction by using thereference pixel, and may generate prediction samples of the input blockby using the spatial prediction. Here, intra prediction may meanintra-frame prediction.

When the prediction mode is the inter mode, the motion prediction unit111 may search for a region that is optimally matched with the inputblock from a reference picture in a motion predicting process, and mayderive a motion vector by using the searched region. The referencepicture may be stored in the reference picture buffer 190.

The motion compensation unit 112 may generate the prediction block byperforming motion compensation using the motion vector. Here, the motionvector may be a two-dimensional vector that is used for interprediction. In addition, the motion vector may indicate offset betweenthe current picture and the reference picture. Here, inter predictionmay be mean inter-frame prediction.

The subtractor 125 may generate a residual block by using the residualsbetween the input block and the prediction block. The residual block maybe referred to as a residual signal.

The transform unit 130 may generate a transform coefficient bytransforming the residual block, and may output the transformcoefficient. Here, the transform coefficient may be a coefficient valuegenerated by transforming the residual block. In a transform skip mode,the transform unit 130 may skip the transforming of the residual block.

A quantized transform coefficient level may be generated by applyingquantization to the transform coefficient. Hereinafter, the quantizedtransform coefficient level may be referred to as the transformcoefficient in the embodiment of the present invention.

The quantization unit 140 may generate the quantized transformcoefficient level by quantizing the transform coefficient depending onthe quantization parameter, and may output the quantized transformcoefficient level. Here, the quantization unit 140 may quantize thetransform coefficient by using a quantization matrix.

The entropy encoding unit 150 may generate the bitstream by performingentropy encoding according to the probability distribution, on valuescalculated by the quantization unit 140 or on coding parameter valuescalculated in an encoding process, etc., and may output the generatedbitstream. The entropy encoding unit 150 may perform the entropyencoding on information for decoding an image, and on information of apixel of an image. For example, the information for decoding an imagemay include a syntax element, etc.

When the entropy encoding is applied, symbols are represented byallocating a small number of bits to the symbols having high occurrenceprobability and allocating a large number of bits to the symbols havinglow occurrence probability, thereby reducing the size of the bitstreamof encoding target symbols. Therefore, compression performance of theimage encoding may be increased through the entropy encoding. For theentropy encoding, the entropy encoding unit 150 may use an encodingmethod such as exponential golomb, context-adaptive variable lengthcoding (CAVLC), and context-adaptive binary arithmetic coding (CABAC).For example, the entropy encoding unit 150 may perform the entropyencoding by using a variable length coding/code (VLC) table. Inaddition, the entropy encoding unit 150 may derive a binarization methodof the target symbol and a probability model of the target symbol/bin,and may perform arithmetic coding by using the derived binarizationmethod or the derived probability model thereafter.

In order to encode the transform coefficient level, the entropy encodingunit 150 may change a two-dimensional block form coefficient into aone-dimensional vector form by using a transform coefficient scanningmethod. For example, the two-dimensional form coefficient may be changedinto the one-dimensional vector form by scanning the coefficient of theblock with up-right scanning. According to the size of the transformunit and the intra-prediction mode, instead of the up-right scanning, itis possible to use vertical direction scanning for scanning thetwo-dimensional block form coefficient in a column direction, andhorizontal direction scanning for scanning the two-dimensional blockform coefficient in a row direction. That is, it is possible todetermine which scanning method among up-right scanning, verticaldirection scanning, and horizontal direction scanning is to be useddepending on the size of the transform unit and the intra-predictionmode.

The coding parameter may include information, such as the syntaxelement, which is encoded by the encoder and is transmitted to thedecoder, and may include information that may be derived in the encodingor decoding process. The coding parameter may mean information that isnecessary to encode or decode an image. For example, the codingparameter may include at least one value or combined form of the blocksize, the block depth, the block partition information, the unit size,the unit depth, the unit partition information, the partition flag of aquad-tree form, the partition flag of a binary-tree form, the partitiondirection of a binary-tree form, the intra-prediction mode, theintra-prediction direction, the reference sample filtering method, theprediction block boundary filtering method, the filter tap, the filtercoefficient, the inter-prediction mode, the motion information, themotion vector, the reference picture index, the inter-predictiondirection, the inter-prediction indicator, the reference picture list,the motion vector predictor, the motion vector candidate list, theinformation about whether or not the motion merge mode is used, themotion merge candidate, motion merge candidate list, the informationabout whether or not the skip mode is used, interpolation filter type,the motion vector size, accuracy of motion vector representation, thetransform type, the transform size, the information about whetheradditional (secondary) transform is used, the information about whetheror not a residual signal is present, the coded block pattern, the codedblock flag, the quantization parameter, the quantization matrix, thefilter information within a loop, the information about whether or not afilter is applied within a loop, the filter coefficient within a loop,binarization/inverse binarization method, the context model, the contextbin, the bypass bin, the transform coefficient, transform coefficientlevel, transform coefficient level scanning method, the imagedisplay/output order, slice identification information, slice type,slice partition information, tile identification information, tile type,tile partition information, the picture type, bit depth, and theinformation of a luma signal or a chroma signal.

The residual signal may mean the difference between the original signaland the prediction signal. Alternatively, the residual signal may be asignal generated by transforming the difference between the originalsignal and the prediction signal. Alternatively, the residual signal maybe a signal generated by transforming and quantizing the differencebetween the original signal and the prediction signal. The residualblock may be the residual signal of a block unit.

When the encoding apparatus 100 performs encoding by using interprediction, the encoded current picture may be used as a referencepicture for another image(s) that will be processed thereafter.Accordingly, the encoding apparatus 100 may decode the encoded currentpicture, and may store the decoded image as the reference picture. Inorder to perform the decoding, dequantization and inverse transform maybe performed on the encoded current picture.

A quantized coefficient may be dequantized by the dequantization unit160, and may be inversely transformed by the inverse transform unit 170.The dequantized and inversely transformed coefficient may be added tothe prediction block by the adder 175, whereby a reconstructed block maybe generated.

The reconstructed block may pass the filter unit 180. The filter unit180 may apply at least one of a deblocking filter, a sample adaptiveoffset (SAO), and an adaptive loop filter (ALF) to the reconstructedblock or a reconstructed picture. The filter unit 180 may be referred toas an in-loop filter.

The deblocking filter may remove block distortion that occurs atboundaries between the blocks. In order to determine whether or not thedeblocking filter is operated, it is possible to determine whether ornot the deblocking filter is applied to the current block on the basisof the pixels included in several rows or columns in the block. When thedeblocking filter is applied to the block, a strong filter or a weakfilter may be applied depending on required deblocking filteringstrength. In addition, in applying the deblocking filter, horizontaldirection filtering and vertical direction filtering may be processed inparallel.

The sample adaptive offset may add an optimum offset value to the pixelvalue in order to compensate for an encoding error. The sample adaptiveoffset may correct an offset between the deblocking filtered image andthe original picture for each pixel. In order to perform the offsetcorrection on a specific picture, it is possible to use a method ofapplying an offset in consideration of edge information of each pixel ora method of partitioning pixels of an image into the predeterminednumber of regions, determining a region to be subjected to perform anoffset correction, and applying the offset correction to the determinedregion.

The adaptive loop filter may perform filtering on the basis of a valueobtained by comparing the reconstructed picture and the originalpicture. Pixels of an image may be partitioned into predeterminedgroups, one filter being applied to each of the groups is determined,and different filtering may be performed at each of the groups.Information about whether or not the adaptive loop filter is applied tothe luma signal may be transmitted for each coding unit (CU). A shapeand a filter coefficient of an adaptive loop filter being applied toeach block may vary. In addition, an adaptive loop filter having thesame form (fixed form) may be applied regardless of characteristics of atarget block.

The reconstructed block that passed the filter unit 180 may be stored inthe reference picture buffer 190.

FIG. 2 is a block diagram showing configurations of a decoding apparatusaccording to an embodiment of the present invention.

The decoding apparatus 200 may be a video decoding apparatus or an imagedecoding apparatus.

Referring to FIG. 2 , the decoding apparatus 200 may include an entropydecoding unit 210, a dequantization unit 220, an inverse transform unit230, an intra-prediction unit 240, a motion compensation unit 250, anadder 255, a filter unit 260, and a reference picture buffer 270.

The decoding apparatus 200 may receive the bitstream outputted from theencoding apparatus 100. The decoding apparatus 200 may decode thebitstream in the intra mode or the inter mode. In addition, the decodingapparatus 200 may generate a reconstructed picture by performingdecoding, and may output the reconstructed picture.

When a prediction mode used in decoding is the intra mode, the switchmay be switched to intra. When the prediction mode used in decoding isthe inter mode, the switch may be switched to inter.

The decoding apparatus 200 may obtain the reconstructed residual blockfrom the inputted bitstream, and may generate the prediction block. Whenthe reconstructed residual block and the prediction block are obtained,the decoding apparatus 200 may generate the reconstructed block, whichis a decoding target block, by adding the reconstructed residual blockand the prediction block. The decoding target block may be referred toas a current block.

The entropy decoding unit 210 may generate symbols by performing entropydecoding on the bitstream according to the probability distribution. Thegenerated symbols may include a symbol having a quantized transformcoefficient level. Here, a method of entropy decoding may be similar tothe above-described method of the entropy encoding. For example, themethod of the entropy decoding may be an inverse process of theabove-described method of the entropy encoding.

In order to decode the transform coefficient level, the entropy decodingunit 210 may perform transform coefficient scanning, whereby theone-dimensional vector form coefficient can be changed into thetwo-dimensional block form. For example, the one-dimensional vector formcoefficient may be changed into a two-dimensional block form by scanningthe coefficient of the block with up-right scanning. According to thesize of the transform unit and the intra-prediction mode, instead ofup-right scanning, it is possible to use vertical direction scanning andhorizontal direction scanning. That is, it is possible to determinewhich scanning method among up-right scanning, vertical directionscanning, and horizontal direction scanning is used depending on thesize of the transform unit and the intra-prediction mode.

The quantized transform coefficient level may be dequantized by thedequantization unit 220, and may be inversely transformed by the inversetransform unit 230. The quantized transform coefficient level isdequantized and is inversely transformed so as to generate areconstructed residual block. Here, the dequantization unit 220 mayapply the quantization matrix to the quantized transform coefficientlevel.

When the intra mode is used, the intra-prediction unit 240 may generatea prediction block by performing the spatial prediction that uses thepixel value of the previously decoded block that is adjacent to thedecoding target block.

When the inter mode is used, the motion compensation unit 250 maygenerate the prediction block by performing motion compensation thatuses both the motion vector and the reference picture stored in thereference picture buffer 270.

The reconstructed residual block may be added to the prediction block bythe adder 255. A block generated by adding the reconstructed residualblock and the prediction block may pass the filter unit 260. The filterunit 260 may apply at least one of the deblocking filter, the sampleadaptive offset, and the adaptive loop filter to the reconstructed blockor to the reconstructed picture. The filter unit 260 may output thereconstructed picture. The reconstructed picture may be stored in thereference picture buffer 270, and may be used for inter prediction.

FIG. 3 is a view schematically showing a partition structure of an imagewhen encoding and decoding the image. FIG. 3 schematically shows anembodiment of partitioning one unit into a plurality of sub-units.

In order to efficiently partition an image, a coding unit (CU) may beused in encoding and decoding. Here, the coding unit may mean anencoding unit. The unit may be a combination of 1) a syntax element and2) a block including image samples. For example, “partition of a unit”may mean “partition of a block relative to a unit”. The block partitioninformation may include information about the unit depth. Depthinformation may indicate the number of times a unit is partitioned or apartitioned degree of a unit or both.

Referring to FIG. 3 , an image 300 is sequentially partitioned for eachlargest coding unit (LCU), and a partition structure is determined foreach LCU. Here, the LCU and a coding tree unit (CTU) have the samemeaning. One unit may have depth information based on a tree structure,and may be hierarchically partitioned. Each of the partitioned sub-unitsmay have depth information. The depth information indicates the numberof times a unit is partitioned or a partitioned degree of a unit orboth, and thus, the depth information may include information about thesize of the sub-unit.

The partition structure may mean distribution of a coding unit (CU) inthe LCU 310. The CU may be a unit for efficiently encoding/decoding animage. The distribution may be determined on the basis of whether or notone CU will be partitioned in plural (a positive integer equal to ormore than 2 including 2, 4, 8, 16, etc.). The width size and the heightsize of the partitioned CU may respectively be a half width size and ahalf height size of the original CU. Alternatively, according to thenumber of partitionings, the width size and the height size of thepartitioned CU may respectively be smaller than the width size and theheight size of the original CU. The partitioned CU may be recursivelypartitioned into a plurality of further partitioned CUs, wherein thefurther partitioned CU has a width size and a height size smaller thanthose of the partitioned CU in the same partition method.

Here, the partition of a CU may be recursively performed up to apredetermined depth. Depth information may be information indicating asize of the CU, and may be stored in each CU. For example, the depth ofthe LCU may be 0, and the depth of a smallest coding unit (SCU) may be apredetermined maximum depth. Here, the LCU may be a coding unit having amaximum size as described above, and the SCU may be a coding unit havinga minimum size.

Whenever the LCU 310 begins to be partitioned, and the width size andthe height size of the CU are decreased by the partitioning, the depthof a CU is increased by 1. In a case of a CU which cannot bepartitioned, the CU may have a 2N×2N size for each depth. In a case of aCU that can be partitioned, the CU having a 2N×2N size may bepartitioned into a plurality of N×N-size CUs. The size of N is reducedby half whenever the depth is increased by 1.

For example, when one coding unit is partitioned into four sub-codingunits, a width size and a height size of one of the four sub-codingunits may respectively be a half width size and a half height size ofthe original coding unit. For example, when a 32×32-size coding unit ispartitioned into four sub-coding units, each of the four sub-codingunits may have a 16×16 size. When one coding unit is partitioned intofour sub-coding units, the coding unit may be partitioned in a quad-treeform.

For example, when one coding unit is partitioned into two sub-codingunits, a width size or a height size of one of the two sub-coding unitsmay respectively be a half width size or a half height size of theoriginal coding unit. For example, when a 32×32-size coding unit isvertically partitioned into two sub-coding units, each of the twosub-coding units may have a 16×32 size. For example, when a 32×32-sizecoding unit is horizontally partitioned into two sub-coding units, eachof the two sub-coding units may have a 32×16 size. When one coding unitis partitioned into two sub-coding units, the coding unit may bepartitioned in a binary-tree form.

Referring to FIG. 3 , the size of the LCU having a minimum depth of 0may be 64×64 pixels, and the size of the SCU having a maximum depth of 3may be 8×8 pixels. Here, a CU having 64×64 pixels, which is the LCU, maybe denoted by a depth of 0, a CU having 32×32 pixels may be denoted by adepth of 1, a CU having 16×16 pixels may be denoted by a depth of 2, anda CU having 8×8 pixels, which is the SCU, may be denoted by a depth of3.

In addition, information about whether or not a CU will be partitionedmay be represented through partition information of a CU. The partitioninformation may be 1 bit information. The partition information may beincluded in all CUs other than the SCU. For example, when a value of thepartition information is 0, a CU may not be partitioned, and when avalue of the partition information is 1, a CU may be partitioned.

FIG. 4 is a view showing forms of a prediction unit (PU) that may beincluded in a coding unit (CU).

A CU that is no longer partitioned, from among CUs partitioned from theLCU, may be partitioned into at least one prediction unit (PU). Thisprocess may be also referred to as a partition.

The PU may be a basic unit for prediction. The PU may be encoded anddecoded in any one of a skip mode, an inter mode, and an intra mode. ThePU may be partitioned in various forms depending on the modes.

In addition, the coding unit may not be partitioned into a plurality ofprediction units, and the coding unit and the prediction unit have thesame size.

As shown in FIG. 4 , in the skip mode, the CU may not be partitioned. Inthe skip mode, a 2N×2N mode 410 having the same size as a CU withoutpartition may be supported.

In the inter mode, 8 partitioned forms may be supported within a CU. Forexample, in the inter mode, the 2N×2N mode 410, a 2N×N mode 415, an N×2Nmode 420, an N×N mode 425, a 2N×nU mode 430, a 2N×nD mode 435, an nL×2Nmode 440, and an nR×2N mode 445 may be supported. In the intra mode, the2N×2N mode 410 and the N×N mode 425 may be supported.

One coding unit may be partitioned into one or more prediction units.One prediction unit may be partitioned into one or more sub-predictionunits.

For example, when one prediction unit is partitioned into foursub-prediction units, a width size and a height size of one of the foursub-prediction units may be a half width size and a half height size ofthe original prediction unit. For example, when a 32×32-size predictionunit is partitioned into four sub-prediction units, each of the foursub-prediction units may have a 16×16 size. When one prediction unit ispartitioned into four sub-prediction units, the prediction unit may bepartitioned in the quad-tree form.

For example, when one prediction unit is partitioned into twosub-prediction units, a width size or a height size of one of the twosub-prediction units may be a half width size or a half height size ofthe original prediction unit. For example, when a 32×32-size predictionunit is vertically partitioned into two sub-prediction units, each ofthe two sub-prediction units may have a 16×32 size. For example, when a32×32-size prediction unit is horizontally partitioned into twosub-prediction units, each of the two sub-prediction units may have a32×16 size. When one prediction unit is partitioned into twosub-prediction units, the prediction unit may be partitioned in thebinary-tree form.

FIG. 5 is a view showing forms of a transform unit (TU) that may beincluded in a coding unit (CU).

A transform unit (TU) may be a basic unit used for a transform,quantization, a reverse transform, and dequantization within a CU. TheTU may have a square shape or a rectangular shape, etc. The TU may bedependently determined by a size of a CU or a form of a CU or both.

A CU that is no longer partitioned among CUs partitioned from the LCUmay be partitioned into at least one TU. Here, the partition structureof the TU may be a quad-tree structure. For example, as shown in FIG. 5, one CU 510 may be partitioned once or more depending on the quad-treestructure. The case where one CU is partitioned at least once may bereferred to as recursive partition. Through the partitioning, one CU 510may be formed of TUs having various sizes. Alternatively, a CU may bepartitioned into at least one TU depending on the number of verticallines partitioning the CU or the number of horizontal lines partitioningthe CU or both. The CU may be partitioned into TUs that are symmetricalto each other, or may be partitioned into TUs that are asymmetrical toeach other. In order to partition the CU into TUs that are symmetricalto each other, information of a size/shape of the TU may be signaled,and may be derived from information of a size/shape of the CU.

In addition, the coding unit may not be partitioned into transformunits, and the coding unit and the transform unit may have the samesize.

One coding unit may be partitioned into at least one transform unit, andone transform unit may be partitioned into at least one sub-transformunit.

For example, when one transform unit is partitioned into foursub-transform units, a width size and a height size of one of the foursub-transform units may respectively be a half width size and a halfheight size of the original transform unit. For example, when a32×32-size transform unit is partitioned into four sub-transform units,each of the four sub-transform units may have a 16×16 size. When onetransform unit is partitioned into four sub-transform units, thetransform unit may be partitioned in the quad-tree form.

For example, when one transform unit is partitioned into twosub-transform units, a width size or a height size of one of the twosub-transform units may respectively be a half width size or a halfheight size of the original transform unit. For example, when a32×32-size transform unit is vertically partitioned into twosub-transform units, each of the two sub-transform units may have a16×32 size. For example, when a 32×32-size transform unit ishorizontally partitioned into two sub-transform units, each of the twosub-transform units may have a 32×16 size. When one transform unit ispartitioned into two sub-transform units, the transform unit may bepartitioned in the binary-tree form.

When performing transform, the residual block may be transformed byusing at least one of predetermined transform methods. For example, thepredetermined transform methods may include discrete cosine transform(DCT), discrete sine transform (DST), KLT, etc. Which transform methodis applied to transform the residual block may be determined by using atleast one of inter-prediction mode information of the prediction unit,intra-prediction mode information of the prediction unit, and size/shapeof the transform block. Information indicating the transform method maybe signaled.

FIG. 6 is a view for explaining an embodiment of a process of intraprediction.

The intra-prediction mode may be a non-directional mode or a directionalmode. The non-directional mode may be a DC mode or a planar mode. Thedirectional mode may be a prediction mode having a particular directionor angle, and the number of directional modes may be M which is equal toor greater than one. The directional mode may be indicated as at leastone of a mode number, a mode value, and a mode angle.

The number of intra-prediction modes may be N which is equal to orgreater than one, including the non-directional and directional modes.

The number of intra-prediction modes may vary depending on the size of ablock. For example, when the size is 4×4 or 8×8, the number may be 67,and when the size is 16×16, the number may be 35, and when the size is32×32, the number may be 19, and when the size is 64×64, the number maybe 7.

The number of intra-prediction modes may be fixed to N regardless of thesize of a block. For example, the number may be fixed to at least one of35 or 67 regardless of the size of a block.

The number of intra-prediction modes may vary depending on a type of acolor component. For example, the number of prediction modes may varydepending on whether a color component is a luma signal or a chromasignal.

Intra encoding and/or decoding may be performed by using a sample valueor an encoding parameter included in a reconstructed neighboring block.

For encoding/decoding a current block in intra prediction, whether ornot samples included in a reconstructed neighboring block are availableas reference samples of an encoding/decoding target block may beidentified. When there are samples that cannot be used as referencesamples of the encoding/decoding target block, sample values are copiedand/or interpolated into the samples that cannot be used as thereference samples by using at least one of samples included in thereconstructed neighboring block, whereby the samples that cannot be usedas reference samples can be used as the reference samples of theencoding/decoding target block.

In intra prediction, based on at least one of an intra-prediction modeand the size of the encoding/decoding target block, a filter may beapplied to at least one of a reference sample or a prediction sample.Here, the encoding/decoding target block may mean a current block, andmay mean at least one of a coding block, a prediction block, and atransform block. A type of a filter being applied to a reference sampleor a prediction sample may vary depending on at least one of theintra-prediction mode or size/shape of the current block. The type ofthe filter may vary depending on at least one of the number of filtertaps, a filter coefficient value, or filter strength.

In a non-directional planar mode among intra-prediction modes, whengenerating a prediction block of the encoding/decoding target block, asample value in the prediction block may be generated by using aweighted sum of an upper reference sample of the current sample, a leftreference sample of the current sample, an upper right reference sampleof the current block, and a lower left reference sample of the currentblock according to the sample location.

In a non-directional DC mode among intra-prediction modes, whengenerating a prediction block of the encoding/decoding target block, itmay be generated by an average value of upper reference samples of thecurrent block and left reference samples of the current block. Inaddition, filtering may be performed on one or more upper rows and oneor more left columns adjacent to the reference sample in theencoding/decoding block by using reference sample values.

In a case of multiple directional modes (angular mode) amongintra-prediction modes, a prediction block may be generated by using theupper right and/or lower left reference sample, and the directionalmodes may have different direction. In order to generate a predictionsample value, interpolation of a real number unit may be performed.

In order to perform an intra-prediction method, an intra-prediction modeof a current prediction block may be predicted from an intra-predictionmode of a neighboring prediction block that is adjacent to the currentprediction block. In a case of prediction the intra-prediction mode ofthe current prediction block by using mode information predicted fromthe neighboring intra-prediction mode, when the current prediction blockand the neighboring prediction block have the same intra-predictionmode, information that the current prediction block and the neighboringprediction block have the same intra-prediction mode may be transmittedby using predetermined flag information. When the intra-prediction modeof the current prediction block is different from the intra-predictionmode of the neighboring prediction block, intra-prediction modeinformation of the encoding/decoding target block may be encoded byperforming entropy encoding.

FIG. 7 is a view depicting a method for performing intra prediction on acurrent block according to an embodiment of the present invention.

As illustrated in FIG. 7 , intra prediction may include deriving anintra prediction mode (S1210), constructing a reference sample (S1220),and/or performing intra prediction (S1230).

In the step of deriving an intra prediction mode (S1210), an intraprediction mode of a neighbor block may be used, an intra predictionmode of a current block may be decoded (e.g., entropy-decoded) from abitstream, and/or the intra prediction mode of the current block may bederived using a coding parameter of a neighbor block. Or, in the step ofderiving an intra prediction mode (S1210), the intra prediction mode ofthe current block may be derived, using an intra prediction mode of aneighbor block, a combination of one or more intra prediction modes ofneighbor blocks, and/or an intra prediction mode derived by MPM.

In the step of constructing a reference sample (S1220), a referencesample may be constructed by performing reference sample selectionand/or reference sample filtering.

In the step of performing intra prediction (S1230), intra prediction maybe performed for the current block, using non-directional prediction,directional prediction, location information-based prediction, and/orluma/chroma signal-based prediction. In the step of performing intraprediction (S1230), filtering may be additionally performed on aprediction sample. If directional prediction is performed, differentdirectional predictions may be performed according to one or more sampleunits. For example, the one or more sample units may be a single sample,a sample group, a line, and/or a sub-block.

Hereinbelow, the step of deriving an intra prediction mode (S1210) willbe described in greater detail.

As described before, to derive the intra prediction mode of the currentblock, at least one of a method for using intra prediction modes of oneor more neighbor blocks, a method for decoding an intra prediction modeof a current block from a bitstream, and a method for using a codingparameter of a neighbor block may be used. A neighbor block(s) may beone or more blocks reconstructed before encoding/decoding of the currentblock.

If the neighbor block is located outside the boundary of at least onepredetermined unit such as a picture, a slice, a tile, and a Coding TreeUnit (CTU), or a PCM mode or inter prediction has been applied to theneighbor block, it may be determined that the neighbor block isunavailable. An intra prediction mode corresponding to the unavailableneighbor block may be replaced with a DC mode, a Planar mode, or apredetermined intra prediction mode.

The current block maybe of size W×H where W and H are positive integersand may be equal or different. W and/or H may be at least one of, forexample, 2, 4, 8, 16, 32, 64, 128, 256, and 512.

FIG. 8 is a view depicting a method for deriving an intra predictionmode of a current block from a neighbor block.

In FIG. 8 , a to k marked on neighbor blocks may denote intra predictionmodes of the neighbor blocks or the numbers of the intra predictionmodes. The position of a neighbor block used to derive the intraprediction mode of the current block may be a predefined fixed position.Or information about the position of the neighbor block may be derivedby encoding/decoding. In the present disclosure, encoding/decoding maybe used to include entropy encoding and decoding.

In the case where an intra prediction mode of a neighbor block is used,a specific mode of a neighbor block may be derived as the intraprediction mode of the current block. For example, intra prediction modei, f, b, g, h, j, l or e of a neighbor block adjacent to a predeterminedposition of the current block may be derived as the intra predictionmode of the current block. The predetermined position may beencoded/decoded from a bitstream or may be derived based on a codingparameter.

Or one or more of the neighbor blocks of the current block may beselected. The selection may be made based on information explicitlysignaled by a bitstream. Or the selection may be made according to acriterion preset between an encoder and a decoder. The intra predictionmode of the current block may be derived from the intra prediction modesof the selected one or more neighbor blocks. For example, the intraprediction mode of the current block may be derived using a statisticvalue of the intra prediction modes of the selected neighbor blocks. Forexample, the statistic value may include a minimum value, a maximumvalue, a mean value, a weighted mean, a most frequent value, and/or amedian value.

For example, a statistic value of a part or all of intra predictionmodes b, f, g, i and j of neighboring blocks may be derived as the intraprediction mode of the current block.

Or, the intra prediction mode of the current block may be derived bycombining the intra prediction modes of one or more neighbor blocks. Anintra prediction mode may be represented as at least one of a modenumber, a mode value, and a mode angle. For example, the mean of one ormore intra prediction modes of neighbor blocks may be derived as theintra prediction mode of the current block. The mean of two intraprediction modes may refer to at least one of a median number betweentwo mode numbers, the median value of two mode values, and the medianangle between two mode angles.

For example, a mode corresponding to the mean of the mode values ofintra prediction modes i and f of the neighbor blocks to which the leftand upper samples adjacent to the sample (0, 0) of the current blockbelong may be derived as the intra prediction of the current block. Forexample, the intra prediction mode of the current block, Pred_mode maybe derived by at least one of methods (1), (2), and (3) described in[Equation 1].

[Equation 1]

Pred_mode=(i+f)>>1  (1)

Pred_mode=(i+f+1)>>1  (2)

Pred_mode=(i+f)/2  (3)

Or if intra prediction mode i of the neighbor block is a non-directionalmode, the intra prediction mode of the current block may be derived asintra prediction mode i. Or, if intra prediction mode f of the neighborblock is a directional mode, the intra prediction mode of the currentblock may be derived as intra prediction mode f.

Or, the intra prediction mode of the current block may be derived as amode corresponding to the mean of at least one of the mode values ofintra prediction modes b, f, g, i, and j of the neighbor blocks. Forexample, the intra prediction mode of the current block, Pred_mode maybe derived by at least one of methods (1), (2), (3), and (4) describedin [Equation 2].

[Equation 2]

Pred_mode=(f+g+i+j+2)>>2  (1)

Pred_mode=(b+f+g+i+j)/5  (2)

Pred_mode=(i+f+k+l+2)>>2  (3)

Pred_mode=(b+f+k+i+l)/5  (4)

Or, a mode corresponding to the mean of available intra prediction modesof adjacent neighbor blocks may be derived as the intra prediction modeof the current block. For example, if a left neighbor block of thecurrent block is located outside of the boundary of a picture a tile, aslice, and/or a CTU, or corresponds to at least one of a PCM mode or aninter prediction mode and thus is not available, a mode corresponding toa statistic value of the intra prediction modes (e.g., f and g) of upperneighbor blocks may be derived as the intra prediction mode of thecurrent block.

For example, a weighted mean or weighted sum may be used as the statistvalue of the intra prediction modes of the neighbor blocks. Herein,weights may be assigned based on the directionalities of the intraprediction modes of the neighbor blocks. For example, modes to whichrelatively large weights are assigned may be predefined or signaled. Forexample, the modes to which relatively large weights are assigned may beat least one of a vertical directional mode, a horizontal directionalmode, and a non-directional mode. The same weight or different weightsmay be assigned to these modes. For example, the weighted sum of intraprediction modes i and f may be derived as the intra prediction mode ofthe current block, Pred_mode by [Equation 3] below. In [Equation 3]below, mode f may be a mode to which a relatively large weight isassigned (e.g., a vertical directional mode).

Pred_mode=(i+3*f+2)>>2  [Equation 3]

Or, the weights to be used for the weighted sum may be determined basedon the sizes of the neighbor blocks. For example, if the size of anupper block adjacent to the current block is larger than that of a leftblock adjacent to the current block, a larger weight may be assigned tothe intra prediction mode of the upper adjacent block. Or, a largerweight may be assigned to the intra prediction mode of the smallerneighbor block.

Or, if one or more intra prediction modes of neighbor blocks are anon-directional mode, the non-directional mode may be derived as theintra prediction mode of the current block. Or, the intra predictionmode of the current block may be derived using the intra predictionmodes of neighbor blocks except for the non-directional mode. If all ofthe intra prediction modes of the neighbor blocks are a non-directionalmode, the intra prediction mode of the current block may be derived asat least one of the DC mode or the Planar mode.

Or, the intra prediction mode of the current block may be derived usingMost Probable Mode (MPM) based on the intra prediction mode of aneighbor block. If MPM is used, one or more pieces of information aboutthe intra prediction mode of the current block may be encoded/decoded.

If MPM is used, an MPM list may be configured. The MPM list may includean intra prediction mode derived based on the intra prediction mode of aneighbor block. The MPM list may include N candidate modes. N is apositive integer and may vary depending on the size and/or shape of thecurrent block. Or, information about N may be signaled by a bitstream.

For example, the intra prediction mode of the current block derivedusing the one or more intra prediction modes of the neighbor blocks maybe a candidate mode included in the MPM list.

In the example illustrated in FIG. 8 , the intra prediction modes of theneighbor blocks at the same positions of (−1, H−1), (W−1, −1), (W, −1),(−1, H), and (−1, −1) adjacent to the current block may be used, forexample, the MPM list may be made in the order of j, g, Planar, DC, l,k, and b. Or, the MPM list may be made in the order of i, f, Planar, DC,l, k, and b. A repeated mode may be included once in the MPM list. Ifthe MPM list is not filled up due to the presence of repeated modes, anadditional candidate mode may be included in the list based on the modesincluded in the list. For example, a mode corresponding to +N or —N (Nis a positive integer, for example, 1) of a mode included in the listmay be added to the list. Or, at least one of modes that are notincluded in the list, among a horizontal mode, a vertical mode, a45-degree mode, a 135-degree mode, and a 225-degree mode, may be addedto the list.

An indicator (e.g., prev_intra_luma_pred_flag) indicating whether thesame mode as the intra prediction mode of the current block is presentin the derived MPM list may be encoded in a bitstream or may be decodedfrom a bitstream.

If the indicator indicates the presence of the same mode as the intraprediction mode of the current block in the MPM list, index information(e.g., mpm_idx) indicating which mode it is among the modes included inthe MPM list may be encoded in a bitstream or decoded from a bitstream.The intra prediction mode of the current block may be derived based onthe decoded index information.

If the indicator indicates the absence of the same mode as the intraprediction mode of the current block in the MPM list, information aboutthe intra prediction mode of the current block may be encoded in abitstream or decoded from the bitstream. The intra prediction mode ofthe current block may be derived based on the decoded information aboutthe intra prediction mode of the current block. Herein, intra predictionmodes that are not included in the MPM list may be arranged in at leastone of an ascending order or a descending order. Or one or more of theintra prediction modes that are not included in the MPM list may begrouped into one or more groups. For example, modes corresponding to +Nor −N (N is a positive integer, for example, 1, 2 or 3) of the intraprediction modes included in the MPM list may be grouped into one group.Herein, the group may include a predetermined number of (e.g., 8 or 16)intra prediction modes, and the modes included in the group may not beincluded in the MPM list.

Or a predetermined candidate in the derived MPM list may be derived asthe intra prediction mode of the current block. For example, a modecorresponding to list 0 which is the first mode in the MPM list may bederived as the intra prediction mode of the current block. Or, an indexcorresponding to a predetermined mode in the list may beencoded/decoded, and the corresponding mode may be derived as the intraprediction mode of the current block.

Regarding configuration of the MPM list, one MPM list may be made for ablock of a predetermined size. If the block of the predetermined size isdivided into a plurality of sub-blocks, each of the plurality ofsub-blocks may use the MPM list.

For example, if the current block corresponds to a block of thepredetermined size, an MPM list may be made for the current block. Ifthe current block is divided into one or more sub-blocks, an intraprediction mode may be derived for each of the sub-blocks, using theconstructed MPM list.

Regarding configuration of an MPM list, an MPM list may be made for eachof sub-blocks into which a block of a predetermined size is divided.

For example, if the current block corresponds to a block of thepredetermined size, an MPM list may be made for each sub-block of thecurrent block, using the intra prediction modes of a neighbor block ofthe current block.

Or the intra prediction mode of the current block may be derived, usingat least one of an intra prediction mode of the current block derived byMPM and the intra prediction modes of a neighbor block.

For example, if the intra prediction mode of the current block derivedby MPM is Pred_mpm, the intra prediction mode of the current block maybe derived by changing Pred_mpm to a specific mode, using one or moreintra prediction modes of neighbor blocks.

For example, Pred_mpm may be incremented or decremented by N bycomparing Pred_mpm with the intra prediction mode of a neighbor block insize. Herein, N may be a predetermined integer such as +1, +2, +3, 0,−1, −2, or −3. For example, if Pred_mpm is less than the intraprediction mode of a neighbor block and/or a statistic value of theintra prediction modes of one or more neighbor blocks, Pred_mpm may beincremented. Or, if Pred_mpm is greater than the intra prediction modeof the neighbor block, Pred_mpm may be decremented. Or, the intraprediction mode of the current block may be derived based on Pred_mpmand/or a value compared with Pred_mpm.

In the example illustrated in FIG. 8 , for example, if Pred_mpm is lessthan the mode value of f, Pred_mpm+1 may be derived as the intraprediction mode of the current block. Or, if Pred_mpm is less than theaverage value of the mode values of f and i, Pred_mpm+1 may be derivedas the intra prediction mode of the current block. Or, if Pred_mpm isless than the average value of the mode values of f and i, an increaseof ½ of the difference between Pred_mpm and the average value may bemade. For example, Pred_mpm+{((f+i+1)>>1−Pred_mpm+1)>>1} may be derivedas the intra prediction mode of the current block.

Or, if one of Pred_mpm and the mode of a neighbor block is anon-directional mode and the other is a directional mode, thenon-directional mode may be derived as the intra prediction mode of thecurrent block, or the directional mode may be derived as the intraprediction mode of the current block.

As described before, the intra prediction mode of the current block maybe derived by encoding/decoding. Herein, the intra prediction mode of aneighbor block may not be used. For example, the intra prediction modeof the current block may be derived by entropy-encoding/decoding abitstream.

For example, if the current block is divided into lower blocks orsub-blocks, the intra prediction mode of each of the sub-blocks may bederived, using at least one of the afore-described methods for derivingan intra prediction mode of a current block.

The size of the current block and the size of a sub-block may be M×N. Mand N may be the same or different positive integers. For example, thecurrent block or the sub-block may be at least one of a CTU, CU, SU(signalling unit), QTMax, QTMin, BTMax, BTMin, 4×4, 8×8, 16×16, 32×32,64×64, 128×128, 256×256, 4×8, 8×16, 16×8, 32×64, 32×8, and 4×32 in size.Herein, QTMax and QTMin may represent maximum and minimum sizes whichallow division into a quadtree, respectively, and BTMax and BTMin mayrepresent maximum and minimum sizes which allow division into a binarytree, respectively. Hereinbelow, the size of a sub-block may mean adivision structure of a sub-block.

The sub-block size may vary depending on the size of the current block.For example, 1/N of the horizontal and vertical sizes of the currentblock may be the sub-block size. N may be a positive integer, and may beat least one of 2, 4, 8, 16, 32, and 64. For example, if the currentblock is of size 32×32 and N for 1/N of the horizontal and verticalsizes of the current block is 4, the sub-block size may be 8×8.

Or, the sub-block size may be a predetermined fixed size irrespective ofthe size of the current block. For example, the sub-block size may be aminimum size irrespective of the size of the current block, and may be,for example, 4×4.

Or, the sub-block size may be determined based on the division structureof a neighbor block of the current block. For example, if an adjacentneighbor block is divided, the sub-block size may be determined bydividing the current block.

The sub-block size may be determined based on the intra prediction modeof a neighbor block of the current block. For example, the sub-blocksize may be determined by block division into sub-blocks on the basis ofa boundary by which intra prediction modes of neighbor blocks becomedifferent.

The sub-block size may be determined based on a coding parameter of aneighbor block. For example, the sub-block size may be determined byblock division into sub-blocks based on whether a neighbor block is anintra coding block or an inter coding block.

At least one of the current block size, the sub-block size, and N bywhich a current block is divided may be fixed to a predetermined value.

For example, in the case where a predetermined fixed size for a currentblock is 16×16, if the current block is of size 16×16, the current blockmay be divided into sub-blocks and an intra prediction mode for eachsub-block may be derived.

For example, in the case where a predetermined fixed size for a currentblock is a CTU and N is 4, if the size of the current block is a CTU, anintra prediction mode may be derived on a sub-block basis, eachsub-block resulting from dividing the latitude and longitude of the CTUby 4.

The one or more sub-blocks may further be divided into smaller blocks.For example, if the size of the current block is 32×32 and the sub-blocksize is 16×16, each of one or more sub-blocks may be divided intosmaller blocks each of size 8×8, 4×4, 16×8, 4×16, or the like.

At least one of the current block size, the sub-block size, and N bywhich the current block is divided may be encoded/decoded.

The division structure of a sub-block for the current block may beencoded/decoded. The sub-blocks into which the current block is dividedmay vary in size and/or shape. Further, an intra prediction mode may bederived for each sub-block.

An indicator (e.g., a flag) indicating that the intra prediction mode ofthe current block is derived using the intra prediction mode of aneighbor block may be encoded/decoded. For example, the indicator may beNDIP_flag (Neighbouring mode Dependant Intra Prediction). The indicatormay be encoded/decoded for at least one of the current block or eachsub-block. The indicator may be encoded/decoded, only when the currentblock size or the sub-block size corresponds to a predetermined size ora predetermined size range. The predetermined size may be, for example,64×64 or BTMax. As described before, the current block may be dividedinto a plurality of sub-blocks. The division structure of a sub-blockmay be predefined or encoded/decoded.

If NDIP_flag is 1 for the current block, the intra prediction mode ofthe current block or the intra prediction mode of each sub-block of thecurrent block may be derived using the intra prediction mode of aneighbor block. In this case, at least one of prev_intra_luma_pred_flag,mpm_idx, rem_intra_luma_pred_mode, intra_chroma_pred_mode, split_flag,QB_flag, quadtree_flag, binarytree_flag, and Btype_flag for the currentblock and/or a sub-block may not be encoded/decoded.

For example, if NDIP_flag is 1 for the current block, the intraprediction mode of the current block may be decoded, and then the intraprediction mode of each sub-block may be derived using the decoded intraprediction mode and the intra prediction mode of a neighbor block.Herein, at least one of prev_infra_luma_pred_flag, mpm_idx,rem_intra_luma_pred_mode, intra_chroma_pred_mode, split_flag, QB_flag,quadtree_flag, binarytree_flag, and Btype_flag for the sub-block may notbe encoded/decoded.

If NDIP_flag is 0 for the current block, information related to at leastone of the intra prediction mode of the current block or the sub-blockand division information of a sub-block may be encoded/decoded.

Among the sub-blocks of the current block, the intra prediction mode ofa first sub-block may be derived in a different manner from the othersub-blocks. The first sub-block may be one of a plurality of sub-blocksin the current block. For example, the first sub-block may be a firstsub-block in a Z scan order.

The intra prediction mode of the first sub-block may refer to an initialmode. For example, if the intra prediction mode of each sub-block isderived as the mean of the intra prediction modes of blocks to the leftof and above the sub-block, the initial mode may be derived in adifferent method. The different method for deriving the initial mode maybe at least one of the methods for deriving an intra prediction modeaccording to the present invention.

For example, an N^(th) (e.g., first) mode listed in an MPM list may bederived as the initial mode. Or, the most frequent one of the intraprediction modes of one or more neighbor blocks of the current block maybe derived as the initial mode. Or, an intra prediction modeencoded/decoded for the current block may be derived as the initialmode. Or, an intra prediction mode encoded/decoded for the firstsub-block may be derived as the initial mode.

Regarding derivation of an intra prediction mode for a sub-block in thecurrent block, the intra prediction modes of one or more sub-blocks maybe derived in an arbitrary order. The arbitrary order may be a scanningorder, and scanning may correspond to at least one of raster scanning,upright scanning, vertical scanning, horizontal scanning, diagonalscanning, and zigzag scanning. The number of sub-blocks for which intraprediction modes are derived in the scanning order may be 1 or larger.The arbitrary order may be determined adaptively according to the intraprediction mode of a neighbor block.

Now, a detailed description will be given of the reference sampleconstruction step S1220.

In intra prediction of the current block or a sub-block having a smallersize and/or shape than the current block, a reference sample may beconstructed for the prediction. The following description is given inthe context of the current block, and the current block may mean asub-block. The reference sample may be constructed, using one or morereconstructed samples or sample combinations neighboring to the currentblock. Additionally, filtering may be applied in constructing thereference sample. Herein, the reference sample may be constructed usingeach reconstructed sample on a plurality of reconstructed sample lines,as it is. Or, the reference sample may be constructed after filteringbetween samples on the same reconstructed sample line. Or, the referencesample may be constructed after filtering between samples on differentreconstructed sample lines. The constructed reference sample may bedenoted by ref[m, n], and a reconstructed neighbor sample or a sampleobtained by filtering the reconstructed neighbor sample may be denotedby rec[m, n]. Herein, m or n may be a predetermined integer value.

FIG. 9 is an exemplary view depicting neighbor reconstructed samplelines which may be used for intra prediction of a current block.

A plurality of reconstructed sample lines may be, for example, one ormore left and/or top reconstructed sample lines neighboring to a currentblock. One or more reference samples may be constructed using the one ormore reconstructed sample lines. In the example illustrated in FIG. 9 ,a reference sample may be constructed for intra prediction of a 4×4current block by selecting at least one of a plurality of left and/ortop reconstructed sample lines neighboring to the current block. Herein,left and top reference samples may be constructed, using the same ordifferent reconstructed sample lines. In the example illustrated in FIG.9 , in a directional prediction mode except for the horizontal,vertical, and/or diagonal direction, reference samples may beconstructed for the current block, using one or more reconstructedsamples on one reconstructed sample line.

For example, in the case where the current block is of sizeW(width)×H(height), if the position of a top left sample in the currentblock is (0, 0), a relative position of a top left reference sampleclosest to the sample position may be set to (−1, −1). To derive areference sample for the current block, a weighted sum of one or moreneighbor reconstructed samples may be used. Herein, the distances fromthe reconstructed samples to the current block and the directionality ofan intra prediction mode of the current block may be taken into account.

For example, when a reference sample is constructed for a current codingblock, using one or more reconstructed sample lines neighboring to thecurrent block, the reference sample may be constructed by assigningdifferent weights according to distances from the current block and thedirectionality of the intra prediction mode of the current block.[Equation 4] below describes an example of constructing a referencesample with a weighted sum, using two reconstructed sample linesneighboring to a current block. The weighted sum may be calculated basedon information about the current block (the intra prediction mode, size,shape, and/or division information of the current block) and/orinformation about a neighbor block (the intra prediction mode, size,shape, and/or division information of the neighbor block). For example,a filter applied to the weighted sum (e.g., a 3-tap filter, a 5-tapfilter, a 7-tap filter, and/or an N-tap filter) may be selected, takinginto account at least one of the above pieces of information.

ref[−1,−1]=(rec[−2,−1]+2*rec[−1,−1]+rec[−1,−2]+2)>>2

ref[x,−1]=(rec[x,−2]+3*rec[x,−1]+2)>>2,(x=0˜W+H−1)

ref[−1,y]=(rec[−2,y]+3*rec[−1,y]+2)>>2,(y=0˜W+H−1)  [Equation 4]

Or, a reference sample may be constructed using at least one of the meanvalue, maximum value, minimum value, median value, and most frequentvalue of a plurality of reconstructed samples, based on at least one ofthe distances from the current block or the intra prediction mode of thecurrent block. The plurality of reconstructed samples which are used maybe filtered reconstructed samples from the same or differentreconstructed sample lines.

Or, a reference sample may be constructed based on a change (variation)in the values of a plurality of contiguous reconstructed samples on thesame reconstructed sample line and/or reconstructed samples linesdifferent from each other. For example, a reference sample may beconstructed based on at least one of whether the difference between thevalues of two contiguous reconstructed samples is equal to or largerthan a threshold, whether the values of the two contiguous reconstructedsamples are changed continuously or non-continuously, and so on. Forexample, if the difference between rec[−1, −1] and rec[−2, −1] is equalto or larger than a threshold, ref[−1, −1] may be determined to berec[−1, −1], or a value obtained by applying a weighted mean with apredetermined weight assigned to rec[−1, −1]. For example, if as aplurality of contiguous reconstructed samples are nearer to the currentbloc, the values of the plurality of contiguous reconstructed samplesare changed by n each time, a reference sample, ref[−1, −1] may bedetermined to be rec[−1, −1]−n.

For example, an intra prediction block for the current coding block maybe constructed by assigning different weights according to distancesfrom the current block and/or the directionality, using one or morereconstructed sample lines neighboring to the current block. Forexample, if the number of the one or more reconstructed sample linesneighboring to the current block is 4, all of the four reconstructedsample lines are available, and an intra prediction direction of thecurrent block is top left diagonal (45 degrees), a prediction samplePred(0, 0) for the sample position (0, 0) in the current block may bederived using a weighted sum of four reconstructed samples, rec[−4, −4],rec[−3, −3], rec[−2, −2], and rec[−1, −1], as illustrated in FIG. 9 . Tocalculate the weighted sum, the precision of a filter may be selectedadaptively according to at least one of information about the currentblock (the intra prediction mode, size, shape, and/or divisioninformation of the current block) and/or information about a neighborblock (the intra prediction mode, size, shape, and/or divisioninformation of the neighbor block), as described before. The tap lengthof the filter applied to calculation of the weighted sum is applied maybe equal to or different from the number of the used one or morereconstructed sample lines. In the example illustrated in FIG. 9 , forexample, Pred(0, 0) may be derived using [Equation 5] below.

Pred(0,0)=(w1*rec[−4,−4]+w2*rec[−3,−3]+w3*rec[−2,−2]+w4*rec[−1,−1])  [Equation5]

In [Equation 5], the sum of weights w1 to w4 may or may not be 1. Inaddition, each of the weights may be positive or negative. For example,if the precision of the filter used for calculating the weighted sum is4 bits, shifting may be performed to avoid a rounding error involved indecimal computation. For example, the weight w1 may be 1, the weight w2may be 2, the weight w3 may be 5, and the weight w4 may be 8 in[Equation 6] below. Further, a shift of 4 and an offset of 8(1<<(shift−1)) may be applied.

Pred(0,0)=(w1*rec[−4,−4]+w2*rec[−3,−3]+w3*rec[−2,−2]+w4*rec[−1,−1]+offset)>>shift  [Equation6]

For example, before the prediction sample is constructed, referencesample filtering may be performed on the one or more reconstructedsamples rec[−1, −1], rec[−2, −2], rec[−3, −3], and rec[−4, −4] from eachreconstructed sample line or reconstructed sample lines different eachother, and a weighted sum may be calculated using the filtered values.Herein, the reference sample filtering may be performed by selectivelyapplying any filter (e.g., at least one of a 3-tap filter, a 5-tapfilter, a 7-tap filter, and an N-tap filter) based on at least one ofinformation about the current block (the intra prediction mode, size,shape, and/or division information of the current block) and/orinformation about a neighbor block (the intra prediction mode, size,shape, and/or division information of the neighbor block).

For example, when a prediction sample is constructed using one or morereconstructed sample lines neighboring to the current block, theprediction sample may be constructed using at least one of the meanvalue, maximum value, minimum value, median value, or most frequencyvalue of one or more reconstructed samples on a reconstructed sampleline in consideration of the distances from the current block and/or thedirectionality according to the intra prediction mode. Herein, for thereconstructed samples on the plurality of reconstructed samples linesused, reference sample filtering is performed on each reconstructedsample line or reconstructed sample lines different from each other, andthe mean value, maximum value, minimum value, median value, or mostfrequency value for generating the prediction block may be performed byusing the filtered values.

For example, after a reconstructed block most similar to the currentblock is detected from neighbor reconstructed samples rec[m, n], intraprediction may be performed using information acquired from thereconstructed block. At least one piece of position information (m, n)about the block most similar to the current block may beentropy-encoded/decoded, or may be implicitly derived by performing thesame operation in the decoder and the encoder.

For example, a prediction block most similar to the current block may bepredicted from reconstructed samples, and a residual signal for thecurrent block may be generated using the difference between the currentblock and the prediction block most similar to the current block,detected from the neighbor reconstructed samples.

For example, after a prediction block most similar to the current blockis derived from reconstructed samples, one or more reconstructed samplelines neighboring to the derived reconstructed samples may be used asreference samples for the current block. Or a reference sample for thecurrent block may be derived using at least one of one or more referencesample lines for the current block and one or more reference samplelines neighboring to the prediction block most similar to the currentblock.

For example, a reference sample for the current coding block may beconstructed using a weighted sum of one reference sample line determinedto be best among one or more reference sample lines available for thecurrent block and one reference sample line determined to be best amongone or more reference sample lines neighboring to a prediction blockmost similar to the current block, derived from reconstructed samples.

For example, a top reference sample for the current block may beconstructed from one reference sample line selected from among one ormore reference sample lines available for the current block. Further, aleft reference sample for the current block may be constructed from onereference sample line selected from among one or more reference samplelines neighboring to the prediction block most similar to the currentblock, derived from the reconstructed samples. The selected onereference sample line may be a reference sample line determined to bebest among one or more reference sample lines.

For example, a first residual signal may be acquired by performing intraprediction for the current block, a second residual signal may beacquired by applying a best intra prediction mode obtained from theintra prediction to the prediction block most similar to the currentblock, derived from the reconstructed samples, and a residual signal forthe current block may be generated using the difference between thefirst residual signal and the second residual signal.

The length of a reference sample line may be different for eachreconstructed sample line. For example, reconstructed sample line n maybe constructed to be longer or shorter than reconstructed sample linen−1 by m samples.

Or, each of the reference sample lines may be reconstructed by a shiftaccording to an intra prediction mode. For example, in the absence of areference sample at a position referenced by an intra prediction mode, acorresponding reference sample line may be shifted so that a referencesample may be present at the position. Which reference sample line to beshifted or by how much may be determined based on an intra predictionmode, a prediction angle, and/or the position of a reference sampleline.

As described above, information indicating whether to construct areference sample using only the closest reference sample line or aplurality of reference sample lines may be encoded/decoded. For example,the information may be encoded/decoded at at least one of a sequencelevel, a picture level, a slice level, a tile level, a CTU level, a CUlevel, a PU level, and a TU level. In addition, information about theavailability of a plurality of reference sample lines may be signaled ata higher level.

A reference sample may be selected for intra prediction of the currentblock. For example, left and/or top reference samples immediatelyneighboring to the current block may be used. Or, best reference samplesmay be constructed for the current block by searching all availablereconstructed samples located in an already reconstructed left columnand/or top row.

FIG. 10 is a view depicting an embodiment of reconstructing referencesamples. In FIG. 10 , a part surrounded by a bold line represents acurrent block. Further, each grid represents one sample, and the shadeof the grid may represent the sample value of the sample. That is, gridswith similar shades may correspond to samples having similar samplevalues.

As illustrated in (a) of FIG. 10 , a reference sample above the currentblock may have a relatively low correlation with the current block. Inthis case, reference samples having high correlations with the currentblock may be detected from among all available reconstructed sampleslocated in a row above the current block. Top reference samples for thecurrent block or all reference samples required for intra prediction ofthe current block may be reconstructed, using the detected referencesamples having high correlations. In the example illustrated in (a) ofFIG. 10 , reference samples at position a to position b in the top rowmay be detected as reference samples having high correlations. Then, asillustrated in (b) of FIG. 10 , top reference samples for the currentblock may be reconstructed by shifting the detected reference sampleshaving high correlations.

In the example illustrated in FIG. 10 , information about referencesample shifting (i.e., information about horizontal shifting) may have apositive or negative integer value. In addition, a default value for theinformation about reference sample shifting may be 0. The informationabout reference sample shifting may be encoded/decoded or may beimplicitly derived in the encoder/decoder.

For example, in the case where the position of a top left sample in thecurrent block is (0, 0), if best top reference samples are located tothe left of a position (−1, −1), the information about reference sampleshifting may have a negative value. Further, if best top referencesamples are located to the right of the position (−1, −1), theinformation about reference sample shifting may have a positive value.Or, the information may have negative and positive signs in the oppositemanner to the above cases. Further, the negative and positive signs maybe determined based on any reference sample other than the position (−1,−1).

A unit for shifting reference samples may be determined according to atleast one piece of coding information from among the intra predictionmode, block size, and shape of the current block and/or a neighborblock, and/or the size, shape, and/or division information of atransform unit. For example, a reference sample may be shifted in unitsof one pixel or any number of pixels.

For example, if a relative position of a top left sample in a currentblock is (0, 0), best top reference samples for the current block may beconstructed using a predetermined unit within a search range withrespect to (−1, −1). The predetermined unit may be at least one of onepixel and a unit based on a block size. The block size-based unit maybe, for example, ½ or ¼ of the block size. Further, the block may be ofany type of block including a transform block. The search range may bean area including all of top reconstructed samples available for thecurrent block. Or the search range may be predefined in theencoder/decoder. Or information about the search range may beencoded/decoded, or may be implicitly derived in the same manner in theencoder/decoder.

For example, the current block may be of size 8×8, and the shifting unitmay be ½ of the current block size, that is, 4. In this case, theencoder/decoder may reconstruct best top reference samples by shiftingfour pixels each time within a configured search range. Herein, forexample, to encode a shift of one unit of pixels (four pixels),information about reference sample shifting may have a value of 1. Forexample, to encode a shift of two units of pixels (8 pixels), theinformation about reference sample shifting may have a value of 2.

For example, the current block may be of size 8×8, and the shifting unitmay be ¼ of the current block size, that is, 2. In this case, theencoder/decoder may reconstruct best top reference samples by shiftingtwo pixels each time within a configured search range. Herein, forexample, to encode a shift of one unit of pixels (two pixels), theinformation about reference sample shifting may have a value of 1.

FIG. 11 is a view depicting another embodiment of reconstructingreference samples. In FIG. 11 , a part surrounded by a bold linerepresents a current block. Further, each grid represents one sample,and the shade of the grid may represent the sample value of the sample.That is, grids with similar shades may correspond to samples havingsimilar sample values.

As illustrated in (a) of FIG. 11 , a reference sample located at a leftside of the current block may have a relatively low correlation with thecurrent block. In this case, reference samples having high correlationswith the current block may be detected from among all availablereconstructed samples located in a left column of the current block.Left reference samples for the current block or all reference samplesrequired for intra prediction of the current block may be reconstructed,using the detected reference samples having high correlations. In theexample illustrated in (a) of FIG. 10 , reference samples at position ato position b in the left column may be detected as reference sampleshaving high correlations. Then, as illustrated in (b) of FIG. 10 , leftreference samples for the current block may be reconstructed by shiftingthe detected reference samples having high correlations.

In the example illustrated in FIG. 10 , information about referencesample shifting (i.e., information about vertical shifting) may have apositive or negative integer value. In addition, a default value for theinformation about reference sample shifting may be 0. The informationabout reference sample shifting may be encoded/decoded or may beimplicitly derived in the encoder/decoder.

For example, in the case where the position of a top left sample in thecurrent block is (0, 0), if best top reference samples are located tothe above of a position (−1, −1), the information about reference sampleshifting may have a negative value. Further, if best top referencesamples are located to the below of the position (−1, −1), theinformation about reference sample shifting may have a positive value.Or, the information may have negative and positive signs in the oppositemanner to the above cases. Further, the negative and positive signs maybe determined based on any reference sample other than the position (−1,−1).

A unit for shifting reference samples may be determined according to atleast one piece of coding information from among the intra predictionmode, block size, and shape of the current block and/or a neighborblock, and/or the size, shape, and/or division information of atransform unit. For example, a reference sample may be shifted in unitsof one pixel or any number of pixels.

For example, if a relative position of a top left sample in a currentblock is (0, 0), best left reference samples for the current block maybe constructed using a predetermined unit within a search range withrespect to (−1, −1). The predetermined unit may be at least one of onepixel and a unit based on a block size. The block size-based unit maybe, for example, ½ or ¼ of the block size. Further, the block may be ofany type of block including a transform block. The search range may bean area including all of left reconstructed samples available for thecurrent block. Or the search range may be predefined in theencoder/decoder. Or information about the search range may beencoded/decoded, or may be implicitly derived in the same manner in theencoder/decoder.

For example, the current block may be of size 8×8, and the shifting unitmay be ½ of the current block size, that is, 4. In this case, theencoder/decoder may reconstruct best left reference samples by shiftingfour pixels each time within a configured search range. Herein, forexample, to encode a shift of one unit of pixels (four pixels),information about reference sample shifting may have a value of 1. Forexample, to encode a shift of two units of pixels (8 pixels), theinformation about reference sample shifting may have a value of 2.

For example, the current block may be of size 8×8, and the shifting unitmay be ¼ of the current block size, that is, 2. In this case, theencoder/decoder may reconstruct best left reference samples by shiftingtwo pixels each time within a configured search range. Herein, forexample, to encode a shift of one unit of pixels (two pixels), theinformation about reference sample shifting may have a value of 1.

The shifting of a reference sample for the current block may be appliedto either available reconstructed samples located in an upper row oravailable reconstructed samples located in a left column. Or, theshifting may be applied to both available reconstructed samples locatedin an upper row and available reconstructed samples located in a leftcolumn. Or, the shifting of a reference sample may be applied to atleast one signal component among a luma component and a chromacomponent.

The shifting of a reference sample for the current block may be appliedto an available reconstructed sample located at a left side and/or anupper side, simultaneously. For example, a shifting of a positivedirection, based on the same shifting information, may mean a shiftingto a right direction of a reconstructed sample located at an upper side,and a shifting to an upper direction of a reconstructed sample locatedat a left side.

When reconstructing a reference sample for the current block using oneor more reconstructed sample lines neighboring to the current block, areconstruction of a reference sample by the shifting of a referencesample may also be applied.

For example, when reconstructing a reference sample for the currentblock using one or more reconstructed sample lines, for each of thereconstructed sample lines, the shifting of a reference sample accordingto the present invention may be applied to at least one among an upperdirection and a left direction to reconstruct a reference sample. Anencoder may construct a reference sample for the current block from anyreconstructed sample line which makes a RD base cost function be thesmallest.

For example, when reconstructing a reference sample for the currentblock using one or more reconstructed sample lines, a reference samplemay be reconstructed by applying the shifting of a reference samplewithin an area configured by one or more reconstructed sample lines. Forexample, when an upper and/or a left reconstructed sample is availableup to four lines, optimal upper and/or left reference sample for thecurrent block may be searched within an area configured by fourreconstructed sample lines. In this case, information (e.g., motioninformation) according to a shift of a horizontal and/or verticaldirection may be encoded/decoded to be transmitted, or may be derivedimplicitly at an encoder/decoder.

When a reference sample for the current block is reconstructed using oneor more reconstructed sample lines, reference samples to bereconstructed may be divided by an arbitrary unit (pixel or any blocksize unit), and reconstructed from a different reconstructed sample linefor each unit (interval).

When shifting a reference sample at an arbitrary position (an upper sideor a left side), in case all reference samples required for the currentblock are available at the shifted position, the shifting of a referencesample may be performed. Or, in case all or a part of reference samplesrequired for the current block are unavailable at the shifted position,the shifting of a reference sample may be performed after padding theunavailable reference samples using an available reference sample in aneighbor. For example, all or a part of reference samples are locatedoutside of boundary of a picture, a tile, a slice, a CTU and/or a CU,the corresponding reference samples may be determined to be unavailable.

After constructing reference samples for intra prediction for thecurrent coding block, reference samples for the current coding block maybe reconstructed by exchanging and/or replacing reference samples in theunit of one or more reference samples.

FIG. 12 is a view depicting another embodiment of reconstructingreference samples. In FIG. 12 , a part surrounded by a bold linerepresents a current block. Further, each grid represents one sample,and the shade of the grid may represent the sample value of the sample.That is, grids having similar shades may correspond to samples havingsimilar sample values.

As illustrated in (a) of FIG. 12 , after reference samples areconstructed, the reference samples of parts A and B each including fourpixels may be subjected to exchange or replacement. For example, thereference samples may be exchanged or replaced in order to reconstructreference samples having high correlations with the current block. Forexample, as illustrated in (b) of FIG. 12 , the values of part A may bereplaced with the values of part B. Or the reference samples of part Amay be exchanged with the reference samples of part B.

In intra prediction of the current block, the current block may bedivided into one or more prediction blocks according to the size and/orshape of the current block. As the same reference sample is referred tofor the prediction blocks, intra prediction of one or more predictionblocks in the current block may be performed in parallel.

FIG. 13 is a view depicting an embodiment of encoding/decoding aplurality of prediction blocks generated by dividing a current block.

As illustrated in FIG. 13 , an 8×8 current block may be divided into two8×4 prediction blocks. In intra prediction of each prediction block,intra prediction may be performed for a second prediction block, usingthe same reference samples as top reference samples used for a firstprediction block. As a result, intra coding/decoding of the first andsecond prediction blocks may be performed simultaneously.

FIG. 14 is a view depicting another embodiment of encoding/decoding aplurality of prediction blocks generated by dividing a current block.

In the example illustrated in FIG. 13 , the top reference samples forthe first prediction block may have low correlations with the secondprediction block. Considering this, after the top reference samples forthe first prediction block are compensated, the compensated topreference samples are referred to as top reference samples for thesecond prediction block, in the example illustrated in FIG. 14 . Forexample, as illustrated in FIG. 14 , the second prediction block may beencoded/decoded based on reference samples obtained by compensating thetop reference samples used for the first prediction block. Herein, acompensation value used for the compensation may be calculated fromneighbor reconstructed samples. For example, the compensation value maybe the difference, A between left reconstructed samples a and b (A=a−b).The compensation value may be used as it is, or after it is scaled toany size according to the same rule in the encoder/decoder.

The foregoing method is also available in the case where intraprediction is performed in parallel for one or more blocks. For example,on the assumption that each of the prediction blocks illustrated inFIGS. 13 and 14 is a (8×4) block, intra prediction may be performed inparallel, using the same reference samples according to the foregoingmethod.

If intra prediction is performed in parallel for one or more blocks, topright samples of a second prediction block (or a lower block) may not beavailable. In this case, top right reference samples of a firstprediction block (or an upper block) may be replicated. Or referencesamples for the second prediction block (or the lower block) may bederived by compensating the top right reference samples of the firstprediction block (or the upper block). A compensation value used for thecompensation may be a difference A or scaled difference A′ calculatedfrom neighbor reconstructed samples.

In the example described with reference to FIG. 14 , neighborreconstructed samples used for calculation of the compensation valueand/or a scaling factor used for the scaling may be determined based onthe shape, size, and/or position of the current block, the firstprediction block, and/or the second prediction block, the position of anarbitrary standard sample, and/or the position of a currently predictedsample.

FIGS. 13 and 14 illustrate cases in which a current block is dividedhorizontally. However, the current block may be divided vertically intoone or more prediction blocks. If the current block is dividedvertically into prediction blocks and each prediction block is processedin parallel, left reference samples for a second prediction block may bederived from left reference samples of a first prediction block, in asimilar manner to that described with reference to FIGS. 13 and 14 . Inthis case, the left reference samples of the first prediction block mayalso be compensated. Further, a compensation value used for thecompensation may be a horizontal difference or scaled difference betweenneighbor reconstructed samples.

After reference samples are constructed in the afore-described variousmethods, a coding mode having a minimum cost function value according torate-distortion optimization may be determined to be an intra predictionmode for the current block.

Information indicating that a reference sample and/or a predictionsample has been constructed in at least one of the afore-describedvarious methods may be encoded/decoded, or may be implicitly derived inthe encoder/decoder. If information about reference sample shifting isexplicitly encoded/decoded, at least one of the following entropyencoding methods may be used. In addition, after the entropy-encodedinformation is binarized, the binarized information may be finallyencoded/decoded by CABAC(ae(v)).

-   -   Truncated Rice binarization method    -   K-th order Exp_Golomb binarization method    -   Limited K-th order Exp_Golomb binarization method    -   Fixed-length binarization method    -   Unary binarization method    -   Truncated Unary binarization method

In selecting the reference sample, a decision as to the availability ofa block including the reference sample and/or padding may be performed.For example, if the block including the reference sample is available,the reference sample may be used. Meanwhile, if the block including thereference sample is not available, the unavailable reference sample maybe replaced with one or more available neighbor reference samples bypadding.

If the reference sample exists outside at least one of a pictureboundary, a tile boundary, a slice boundary, a CTB boundary, and apredetermined boundary, it may be determined that the reference sampleis not available.

In the case where the current block is encoded by CIP (constrained intraprediction), if the block including the reference sample isencoded/decoded in an inter prediction mode, it may be determined thatthe reference sample is not available.

FIG. 15 is a view depicting a method for replacing an unavailablereconstructed sample, using an available reconstructed sample.

If it is determined that the neighbor reconstructed sample isunavailable, the unavailable sample may be replaced, using a neighboravailable reconstructed sample. For example, as illustrated in FIG. 15 ,in the presence of available samples and unavailable samples, anunavailable sample may be replaced, using one or more available samples.

The sample value of an unavailable sample may be replaced with thesample value of an available sample in a predetermined order. Anavailable sample adjacent to an unavailable sample may be used toreplace the unavailable sample. In the absence of an adjacent availablesample, the first appearing available sample or the closest availablesample may be used. A replacement order of unavailable samples may be aleft lowermost to right uppermost order. Or the replacement order ofunavailable samples may be a right uppermost to left lowermost order. Orthe replacement order of unavailable samples may be a left uppermost toright uppermost and/or left lowermost order. Or the replacement order ofunavailable samples may be a right uppermost and/or left lowermost toleft uppermost order.

As illustrated in FIG. 15 , unavailable samples may be replaced in anorder from a left lowermost sample position 0 to a right uppermostsample. In this case, the values of the first four unavailable samplesmay be replaced with the value of the first appearing or closestavailable sample a. The values of the next 13 unavailable samples may bereplaced with the value of the last available sample b.

Or, an unavailable sample may be replaced, using a combination ofavailable samples. For example, the unavailable sample may be replacedusing the mean value of available samples adjacent to both ends of theunavailable sample. For example, in FIG. 15 , the first four unavailablesamples may be filled with the value of the available sample a, and thenext 13 unavailable samples may be filled with the mean value of theavailable sample b and an available sample c. Or, the 13 unavailablesamples may be filled with any value between the values of the availablesamples b and c. In this case, the unavailable samples may be replacedwith difference values. For example, as an unavailable sample is nearerto the available sample a, the value of the unavailable sample may bereplaced with a value close to the value of the available sample a.Similarly, as an unavailable sample is nearer to the available sample b,the value of the unavailable sample may be replaced with a value closeto the value of the available sample b. That is, the value of anunavailable sample may be determined based on the distance from theunavailable sample to the available sample a and/or b.

To replace an unavailable sample, one or more of a plurality of methodsincluding the above methods may be selectively applied. A method forreplacing an unavailable sample may be signaled by information includedin a bitstream, or a method predetermined by an encoder and a decodermay be used. Or the method for replacing an unavailable sample may bederived by a predetermined scheme. For example, a method for replacingan unavailable sample may be selected based on the difference betweenthe values of the available samples a and b and/or the number ofunavailable samples. For example, a method for replacing an unavailablesample may be selected based on a comparison between the differencebetween the values of two available samples and a threshold and/or acomparison between the number of unavailable samples and a threshold.For example, if the difference between the values of the two availablesamples is larger than the threshold and/or if the number of unavailablesamples is larger than the threshold, the values of unavailable samplesmay be replaced with different values.

A method for replacing an unavailable sample may be selected on apredetermined unit basis. For example, a method for replacing anunavailable sample may be selected on the basis of at least one of, forexample, a video, a sequence, a picture, a slice, a tile, a CTU, a CU, aPU, and a TU. Herein, selection of a method for replacing an unavailablesample may be based on information signaled on the predetermined unitbasis or derived on the predetermined unit basis. Or a methodpredetermined by an encoder and a decoder may be applied.

FIG. 16 is a view depicting another method for replacing unavailablereconstructed samples, using available reconstructed samples.

In the example illustrated in FIG. 16 , a current block is of size 8×8,and eight samples included in block C to the top right of the currentblock, among top reference samples are unavailable. As illustrated in(a) of FIG. 16 , the values of the 8 unavailable samples may be replacedwith the sample value b of an available sample closest to the eightunavailable samples. Or as illustrated in (b) of FIG. 16 , the values ofthe eight unavailable samples may be replaced with a value b′, insteadof the value b.

The value b′ may be derived, for example, based on the gradient ofreference samples included in block B. To calculate the value b′, forexample, the following pseudo code may be used.

TABLE 1 After the average, avg. of reference samples included in block Bis calculated, b′ is derived in consideration of a gradient with respectto the value b. (1) Compute avg. (2) delta = avg. − b (3) if (delta > 0)b′ = b − scaled_delta (4) if (delta < 0) b′ = b + scaled_delta (5) Else,perform by the conventional method

First, the average of the reference samples included in block B may becalculated. If the current block is of size 8×8, eight reconstructedsamples above the current block may be used in calculating the average.Subsequently, b′ may be derived in consideration of the gradient betweenthe calculated average and the sample value b.

After the difference, delta between the calculated average and thesample value b is calculated, if the difference, delta is larger than 0,it may be considered that the values of the eight reference samplesincluded in block B are gradually decreased. Therefore, b′ may bederived by reflecting the decrement in the sample value b. If thedifference, delta is less than 0, it may be considered that the valuesof the eight reference samples included in block B are graduallyincreased. Therefore, b′ may be derived by reflecting the increment inthe sample value b.

The average, avg. in the pseudo code may be the average of as manyavailable reference samples as the width of the current block. That is,in FIG. 16 , avg. may be the average of the eight reference samplesincluded in block B. However, the number of reference samples used incalculating an average is not limited thereto. For example, in FIG. 16 ,the average may be calculated using at least one of the eight referencesamples included in block B. For example, avg. may be the average of Kavailable reference samples in the vicinity of the unavailable referencesamples. For example, the average may be calculated only from four rightreference samples among the eight reference samples included in block B.

Further, the sample value b of one available reference sample is used tocalculate the difference, delta in the pseudo code, which should not beconstrued as limiting. For example, the difference, delta may becalculated using at least one of the eight reference samples included inblock B. For example, the at least one reference sample used tocalculate the difference, delta may be P available reference samples inthe vicinity of the unavailable reference samples. For example, theaverage of the P reference samples may be used as the difference, delta.The number P of available reference samples used to calculate thedifference, delta may be less than the number K of available referencesamples used to calculate the average.

Further, any other statistic value may be used instead of the average ofK available reference samples and/or the average of P availablereference samples used to derive the difference, delta. The statisticvalue may be at least one of, for example, a weighted mean value, amaximum value, a minimum value, a median value, or a most frequentvalue. If a weighted mean value is used, weights may be determined basedon the position of each of the available reference sample and/or theunavailable reference samples. For example, the weights may be inverselyproportional to the distance between the available reference sample andthe unavailable reference sample.

The value b′ may be calculated by compensating the sample vale b of theavailable reference sample for a gradient corresponding to thedifference, delta. A compensation value used for the compensation may bethe difference, delta or a value, scaled_delta, obtained by scaling thedifference, delta using a scaling factor. The value scaled_delta may belarger or less than delta.

In the example illustrated in (a) of FIG. 16 , the values of eightunavailable reference samples located to the bottom left of the currentblock may be replaced with the sample value a of an available referencesample. Or the values of the eight unavailable reference samples locatedto the bottom left of the current block may be replaced with a samplevalue a′ according to the method described with reference to (b) of FIG.16 . These methods may be applied to all of top and left referencesamples or only to a direction. The direction to which the methods areapplied may be determined based on coding information specifying thesize, shape, and intra prediction mode of the current block.

Further, in the example illustrated in FIG. 16 , the values of the topright or bottom left unavailable reference samples may be replaceduniformly with the value a′ or b′. Or, different values may be appliedto the unavailable reference samples by gradually scaling an initiallyobtained difference, delta.

In the case where at least one reconstructed sample line neighboring toa current block is used, the padding method may also be adaptivelyapplied.

FIG. 17 is an exemplary view depicting padding of reference samples inthe case where one or more reconstructed sample lines are used.

If reference samples are generated for a current coding block, using aplurality of (e.g., up to 4) reconstructed sample lines, top right orbottom left reference samples on each reconstructed sample line may notbe available. After reference samples are generated for the unavailablereference samples in the foregoing method, a reconstructed sample linewhich is optimal in terms of RD may be set as reference samples for thecurrent block.

In the example illustrated in FIG. 17 , in the case where referencesamples are generated for a current block using up to 4 reconstructedsample lines, the reconstructed samples of dotted boxes may not beavailable. Reference samples may be generated for the positions of theunavailable top right or bottom left reconstructed samples, usinginformation of outermost available reconstructed samples (reconstructedsamples in a bold solid lined box) among available reconstructed sampleson the four reconstructed sample lines.

For example, in order to generate unavailable reference samples locatedat a top right of the current block, at least one of four availablereconstructed samples in a bold solid lined box to the top right of thecurrent block may be used. For example, the non-reference samples may bepadded by using at least one of the maximum value, minimum value, medianvalue, mean value, weighted mean value, and most frequent value of Navailable reconstructed samples in the top right bold solid lined box. Nmay be, for example, 4.

Similarly, at least one of four available reconstructed samples in abold solid lined box to the bottom left of the current block may be usedfor unavailable reference samples to the bottom left of the currentblock.

Or, in the example illustrated in FIG. 17 , one or more availablereference samples including or not including an available reconstructedsample in a bold solid lined box may be used for generating theunavailable reference samples.

For the constructed one or more reference samples, whether to applyfiltering and/or a filtering type may be determined in a differentmanner based on at least one of the intra prediction mode, size, and/orshape of the current block. And, the filtering may be applied to atleast one component among a luma and chroma component.

For the plurality of reference sample lines, for example, it may bedetermined differently whether to apply filtering. For example,filtering may be applied to a first adjacent reference sample line, andfiltering may not be applied to a second adjacent reference sample line.

Further, for example, both a filtered value and a non-filtered value maybe used for the same reference sample. For example, at least onedifferent one of a 3-tap filter, a 5-tap filter, a 7-tap filter, and anN-tap filter may be selected and applied according to at least one of anintra prediction mode, and the size and/or shape of the current block.Herein, N may be an integer.

For example, in the case where the values of unavailable samples arereplaced with the same value by using the value of a neighbor availablereference sample, in spite of reference sample filtering, the filteredreference sample values of the reference samples whose values arereplaced with the same value may all be equal. Further, since thefiltered reference sample values are equal, if intra prediction isperformed for the current block, using a weighted sum of the referencesample values, the same prediction sample value may always be achieved.In the above case, therefore, the computation volume of theencoder/decoder may be reduced by skipping the reference samplefiltering operation and/or the operation of deriving a prediction samplevalue.

FIG. 18 is a view depicting filtering of reference samples includingpadded unavailable reference samples.

As illustrated in (a) of FIG. 18 , bottom left and top right unavailablereference samples for the current block may be padded by any values. InFIG. 18 , the position of a top left sample neighboring to the currentblock is (−1, −1). (b) of FIG. 18 illustrates the neighbor bottom leftand top right reference samples in a one-dimensional array. The paddedbottom left and top right reference samples may not be filtered, amongthe reference samples of the one-dimensional array illustrated in (b) ofFIG. 18 . Herein, the padded bottom left samples are included in blockA, and the padded top right samples are included in block B. Theremaining samples except for the padded bottom left and top rightreference samples may be filtered. As described before, at least onedifferent filter may be selected from among a 3-tap filter, a 5-tapfilter, a 7-tap filter, and an N-tap filter according to at least one ofinformation about the current block and/or information about a neighborblock (an intra prediction mode, a block size, a block shape, the sizeof a transform unit, and/or division information). Herein, N may be aninteger. In the example described with reference to FIG. 18 , the sizeof the one-dimensional array is (4*nTbs+1) where nTbs may be the widthor height of the current block or the transform block.

FIG. 19 is a view depicting filtering of reference samples including anunavailable reference sample. For example, if a current block is of size8×8, and left bottom reference samples included in block A and top rightreference samples in block B are unavailable, the unavailable referencesamples may be replaced with the same values, using the values ofneighbor available reference samples.

(a) of FIG. 19 illustrates an example of filtering all reference samplesincluding padded reference samples, and (b) of FIG. 19 illustrates anexample of filtering reference samples except for padded referencesamples.

As illustrated in (b) of FIG. 19 , the reference samples replaced withthe same values may not be subjected to reference sample filtering.Herein, reference sample filtering may be applied only to the remainingreference samples except for the reference samples of block A or blockB. Or, reference sample filtering may be applied only to referencesamples other than a leftmost and/or rightmost reference sample amongthe remaining reference samples except for the reference samples ofblock A or block B. As described before, at least one different filtermay be selected from among a 3-tap filter, a 5-tap filter, a 7-tapfilter, and an N-tap filter according to at least one of informationabout the current block and/or information about a neighbor block (anintra prediction mode, a block size, a block shape, the size of atransform unit, and/or division information). Herein, N may be aninteger.

For example, after the values of unavailable reference samples arereplaced with the same value, using the value of an available referencesample, intra prediction may be performed, using the same referencesample value. In this case, the operation of calculating a weighted sumaccording to a distance and/or a directionality may be skipped.

In the case where one or more reconstructed sample lines neighboring tothe current block are used, if each reconstructed sample line includesan unavailable reference sample, the method described with reference toFIG. 19 may be applied.

If reference samples are padded or filtered in at least one of theforegoing methods, information indicating the padding or filtering maybe encoded/decoded or may be implicitly derived in the encoder/decoder.If the information is explicitly encoded/decoded, at least one of thefollowing entropy encoding methods may be used. In addition, after theentropy-encoded information is binarized, the binarized information maybe finally encoded/decoded by CABAC(ae(v)).

-   -   Truncated Rice binarization method    -   K-th order Exp_Golomb binarization method    -   Limited K-th order Exp_Golomb binarization method    -   Fixed-length binarization method    -   Unary binarization method    -   Truncated Unary binarization method

Now, a detailed description will be given of the step of performingintra prediction (S1230).

Intra prediction may be performed on the current block or sub-blockbased on the derived intra prediction mode and the reference samples. Inthe following detailed description, the current block may mean asub-block.

For example, non-directional intra prediction may be performed as theintra prediction. The non-directional mode may be at least one of, forexample, the DC mode and the Planar mode.

If the non-directional mode is the DC mode, intra prediction may beperformed, using the mean value of one or more of the constructedreference samples. Herein, filtering may be applied to one or moreprediction samples located at the boundary of the current block. Thenumber of mean values may be 1 or larger, and prediction may beperformed, using different mean values according to the positions oftarget samples for prediction. Different reference samples may be usedaccording to at least one of the size or shape of the current block. Forexample, if the size of the block is larger than a predetermined size,one adjacent reference sample line may be used, and if the size of theblock is less than the predetermined size, two adjacent reference samplelines may be used.

If the non-directional mode is the Planar mode, intra prediction may beperformed, using a weighted sum calculated in consideration of distancesfrom the constructed one or more reference samples, according to theposition of a target sample for intra prediction in the current block.

As intra prediction, for example, directional intra prediction may beperformed. The directional mode may be at least one of, for example, ahorizontal mode, a vertical mode, and a mode having a predeterminedangle.

If the directional mode is the horizontal and/or the vertical mode,intra prediction may be performed using at least one reference samplelocated on a horizontal and/or vertical line at the position of a targetsample for intra prediction.

If the directional mode is a mode having a predetermined angle, intraprediction may be performed using one or more samples located on andadjacent to a line at a predetermined angle with respect to the positionof a target sample for intra prediction. Herein, N reference samples maybe used. N may be a positive integer such as 2, 3, 4, 5, and 6, andintra prediction may be performed by applying an N-tap filter such as2-tap, 3-tap, 4-tap, 5-tap, and 6-tap filters. Herein, one or morereference sample lines may be used, and a different filter type may beapplied to each reference sample line. Intra prediction may be performedby calculating a weighted mean of values obtained by applying a filterto each line. The number of reference sample lines used for thedirectional prediction may be different according to at least one of thedirectional mode, the size of the current block, and the shape of thecurrent block.

Or intra prediction may be performed based on location information. Thelocation information may be encoded/decoded, and a reconstructed sampleblock at the position may be derived as an intra prediction block forthe current block. Or a block similar to the current block, searched forby a decoder may be derived as the intra prediction block of the currentblock.

Or, intra prediction may be performed based on a luma signal and/or achroma signal. For example, intra prediction for a chroma signal may beperformed using a reconstructed luma signal of the current block. Forexample, intra prediction for another chroma signal Cr may be performedusing one reconstructed chroma signal Cb of the current block.

Intra prediction may be performed by using one or more of theafore-described various intra prediction methods in combination. Forexample, an intra prediction block may be constructed for the currentblock through a weighted sum of a block predicted using a predeterminednon-directional intra prediction mode and a block predicted using apredetermined directional intra prediction mode. Herein, a differentweight may be applied according to at least one of the intra predictionmode, block size, shape/and or sample position of the current block.

Or, regarding combined use of the one or more intra prediction modes, aprediction block may be constructed using a weighted sum of a valuepredicted using the intra prediction mode of the current block and avalue predicted using a predetermined mode included in an MPM list.

Or, intra prediction may be performed using one or more reference samplesets. For example, intra prediction may be performed for the currentblock, using a weighted sum of a block intra-predicted using a referencesample obtained by not applying filtering to a constructed referencesample, and a block intra-predicted using a reference sample obtained byapplying filtering to the constructed reference sample.

In the process of intra prediction, a filtering operation may beperformed using a neighbor reconstructed sample. Herein, the filteringoperation may or may not be performed according to at least one of theintra prediction mode, block size, shape, and/or sample position of thecurrent block. The filtering operation may be included in the intraprediction process and thus performed as one step.

In performing intra prediction by dividing the current block intosub-blocks and deriving the intra prediction mode of each sub-blockusing the intra prediction mode of a neighbor block, filtering may beapplied to each sub-block of the current block. For example, a low-passfilter may be applied to the entire current block. Or, a filer may beapplied to a sample located on the boundary of each sub-block. Or afilter may be applied to the prediction block or reconstructed block ofeach sub-block, and one or more samples of a sub-block to which thefilter is applied may be used in intra prediction of a subsequentsub-block.

In dividing the current block into sub-blocks and performing intraprediction for each sub-block, each sub-block may refer to at least oneof a coding/decoding block, a prediction block, and a transform block.For example, if the current block is of size 64×64 and a sub-block is ofsize 16×16, the intra prediction mode of a prediction block being eachsub-block may be derived and/or intra prediction may be performed forthe prediction block. If each of the one or more sub-blocks is furtherdivided into 8×8 or 4×4 blocks, each of the 8×8 or 4×4 blocks may be atransform block, and intra prediction may be performed for the blocksobtained by the further division using the intra prediction mode of the16×16 block.

In the directional intra prediction, the current block may beencoded/decoded using at least one of N directional modes. Herein, N maybe a positive integer such as 33 or 65.

In the directional intra prediction, the constructed reference samplemay be reconstructed according to a directional prediction mode. Forexample, if the directional prediction mode is a mode in which all ofleft and upper reference samples are used, a one-directional array maybe constructed with the left or upper reference samples.

FIG. 20 is a view depicting an embodiment of generating a 1D referencesample array p_(1,ref) from P_(ref).

For example, as illustrated in FIG. 20 , a 1D array of upper referencesamples may be constructed using one or more of left reference samples.Different samples out of the left samples may be used to construct theupper reference samples according to the directional mode. The upperreference samples may be constructed by moving the left referencesamples, or the upper reference samples may be constructed by using aweighted sum of one or more left reference samples.

In the directional intra prediction, real number-based interpolatedprediction may be performed. For example, an offset (iIdx) and/or aweight (iFact) for prediction sample interpolation may be determinedaccording to the position of a sample in the current block based on anangle parameter (intraPredAngle) corresponding to each directionalprediction mode, as follows.

For example, on the assumption of interpolation in units of 1/32 pel, anoffset and a weight for a directional mode having a vertical directionmay be determined by the following [Equation 7].

iIdx=((y+1)*intraPredAngle)>>5

iFact=((y+1)*intraPredAngle)&31  [Equation 7]

A different prediction sample value may be determined according to thevalue of iFact in [Equation 7]. For example, if iFact is not 0, aprediction position in a reference sample P_(1,ref) is not aninteger-based location (full sample location) but a real number-basedlocation. Therefore, a prediction sample value at a target sampleposition (x, y) may be generated using a plurality of reference samples(e.g., two left and right adjacent reference samples) adjacent to areal-number position by the following [Equation 8]. Herein, theplurality of adjacent reference samples may be 4 or 6 left and rightadjacent reference samples.

predSamples[x][y]=((32=iFact)*p _(1,ref) [x+iIdx+1]+iFact*p _(1,ref)[x+iIdx+2]+16)>>5[Equation 8]

For example, if iFact is 0, a prediction sample value may be generatedby [Equation 9] below. Or, a 3-tap [1/4:2/4:1/4] filter may be appliedusing the reference sample P_(1,ref) and left and right referencesamples.

predSamples[x][y]=p _(1,ref) [x+iIdx+1]  [Equation 9]

In the case of at least one of the horizontal mode and/or the verticalmode among the directional prediction modes, filtering may not beperformed for a reference sample. In addition, interpolated predictionmay not be needed for the reference sample. Further, since prediction ispossible only with upper or left reference samples, the process ofconstructing a 1D array for the reference sample may not be needed.

Now, a description will be given of the step of performingnon-directional prediction according to the present invention.

In the Planar mode, intra prediction may be performed by calculating aweighted sum in consideration of distances from the one or moreconstructed reference samples according to the position of a targetintra prediction sample in the current block.

FIG. 21 is a view depicting intra prediction according to an embodimentof the present invention.

A current block may be of size 8×8 and its intra prediction mode may bethe Planar mode. In the Planar mode, as illustrated in FIG. 21 , abottom right sample K in the current block may be derived using aweighted sum of a top right reference sample TR and a bottom leftreference sample BL of the current block. The weighted sum may becalculated according to at least one of information about the currentblock and/or information about a neighbor block (an intra predictionmode, a block size, shape, the size of a transform unit, and/or divisioninformation). In the example illustrated in FIG. 21 , the sample K isderived using the weighted sum of TR and BL, which should not construedas limiting. For example, the sample K may be derived through the meanvalue, the minimum value, the maximum value, or any weighted sum of TRand BL.

In the example illustrated in FIG. 21 , after samples included in abottom row of the current block (in block A) are replaced with BL andsamples included in a right column of the current block (in block B) arereplaced with TR, a target prediction sample at a position (x, y) in thecurrent block may be predicted to be a weighted sum based on theposition of the sample. For example, [Equation 10] may be used.

pred[x,y]=(b*L+a*TR+d*T+c*BL+8)>>4  [Equation 10]

Or, in another embodiment, for example, the samples included in thebottom row within the current block (block A) may be derived as weightedsums according to distances of BL and K, and the samples included in theright column within the current block (block B) may be derived asweighted sums according to distances of TR and K. And a predictiontarget sample at an arbitrary position (x, y) within the current blockmay be predicted as a weighted sum based on the position of each sample.Herein, for example, [Equation 10] may be used, and the weighted sumsaccording to distance of TR and K and the weighted sums according todistances of BL and K may be used respectively, instead of TR and BLvalues.

FIG. 22 is a view depicting intra prediction according to anotherembodiment of the present invention.

As illustrated in FIG. 22 , intra prediction may be performed in acombination of the Planar mode and the DC mode in order to generate anintra prediction block for a current block.

In FIG. 22 , a bold solid line represents an 8×8 current block.

As illustrated in (a) of FIG. 22 , after the average value is calculatedusing at least one among reference samples neighboring to the currentblock, 3-tap or 2-tap based filtering may be performed for boundarypixels (shaded pixels) in a left column and a top row within the currentblock based on neighboring reference samples. For example, a filter usedin the filtering may have any of the shapes illustrated on the rightside in (a) of FIG. 22 .

Subsequently, as illustrated in (b) of FIG. 22 , after average valueDCVal is calculated using at least one among reference samplesneighboring to the current block, intra prediction may be performed fora target prediction block including one or more samples neighboring tothe center of the current block (hereinafter, referred to as “centerblock”). The target prediction block may be identical to the 8×8 currentblock or may be smaller, such as 2×2, 3×3, 4×4, or the like, in sizeand/or shape.

For example, as in the Planar mode, a bottom right sample K in thecurrent block may be derived using a weighted sum of a top rightreference sample TR and a bottom right reference sample BL of thecurrent block. The weighted sum may be calculated according to at leastone of information about the current block and/or information about aneighbor block (an intra prediction mode, a block size, a shape, thesize of a transform unit, and/or division information). The sample K isderived using the weighted sum of TR and BL, which should not beconstrued as limiting. For example, the sample K may be derived throughthe mean value, the minimum value, the maximum value, or any weightedsum of TR and BL.

For example, samples included in a bottom row of the current block (inblock A) may be replaced with BL, and samples included in a right columnof the current block (in block B) may be replaced with TR. Or, thesamples included in the bottom row of the current block (in block A) maybe derived as weighted sums according to distances of BL and K, and thesamples included in the right column of the current block (in block B)may be derived as weighted sums according to distances of TR and K.

Subsequently, blocks to the left, to the right, above, and under thecenter block of the current block (blocks marked with “1” in (c) of FIG.22 ) may be predicted. Then, intra prediction may be performed for theremaining blocks (blocks marked with “2” in (d) of FIG. 22 ). Forexample, pixel-wise intra prediction may be performed for the remainingblocks, independently or in parallel.

As described before, the edge pixels and the center block of anarbitrary size in the current block may be predicted. Further,sub-block-wise intra prediction may be performed using at least one ofalready-predicted neighbor sample values, with each sub-block includingat least one target prediction sample. The intra prediction may beperformed according to at least one of information about the currentblock and/or a neighbor block (an intra prediction mode, a block size, ashape, the size of a transform unit, and/or division information).

For example, each of the four sub-blocks (the blocks marked with “1”)illustrated in (c) of FIG. 22 has information about prediction performedon the center, up, down, left, and/or right side according to the abovemethod. Accordingly, intra prediction may be performed for eachsub-block independently or in parallel. The four sub-blocks (the blocksmarked with “2”) illustrated in (d) of FIG. 22 may also be subjected toindependent or parallel sub-block-wise intra prediction based oninformation about already intra-predicted neighbor samples, for example,by calculating weighted sums.

FIG. 23 is a view depicting intra prediction according to anotherembodiment of the present invention.

After reference samples are generated for a current block, the currentblock may be divided into one or more sub-blocks according to the sizeand/or shape of the current block. Subsequently, intra prediction may beperformed by changing the positions of the sub-blocks. The methoddescribed with reference to FIG. 23 may be applied to non-directionalprediction as well as directional prediction.

For example, as illustrated in FIG. 23 , intra prediction may beperformed for an 8×8 current block. Herein, after the positions of foursub-blocks obtained by dividing the current block are changed randomly,intra prediction may be performed. While the current block is shown inFIG. 23 as divided into four sub-blocks, the division of the currentblock is not limited thereto. The current block may be divided into Nsub-blocks, N being equal to or larger than 2.

For example, the current block may be divided into four sub-blocks. Inaddition, after sample values within the current block are reordered ineach sub-block obtained by dividing the current block according to thesame rule defined in the encoder/decoder, intra prediction may beperformed.

For example, after the current block is divided into two or moresub-blocks, the positions of the sub-blocks may be changed or the codingsamples of the sub-blocks may be reordered. Or the change of thepositions of the sub-blocks and the reordering of the samples in thesub-blocks may be performed at the same time.

Information indicating that intra prediction has been performed in atleast one of the methods described with reference to FIGS. 21, 22, and23 may be encoded/decoded, or may be implicitly derived in theencoder/decoder. If the information is explicitly encoded/decoded, atleast one of the following entropy encoding methods may be used. Inaddition, after the entropy-encoded information is binarized, thebinarized information may be finally encoded/decoded by CABAC(ae(v)).

-   -   Truncated Rice binarization method    -   K-th order Exp_Golomb binarization method    -   Limited K-th order Exp_Golomb binarization method    -   Fixed-length binarization method    -   Unary binarization method    -   Truncated Unary binarization method

The intra encoding/decoding process may be performed for each of lumaand chroma signals. For example, in the intra encoding/decoding process,at least one method of deriving an intra prediction mode, dividing ablock, constructing reference samples and performing intra predictionmay be differently applied for a luma signal and a chroma signal.

The intra encoding/decoding process may be equally performed for lumaand chroma signals. For example, in the intra encoding/decoding processbeing applied for the luma signal, at least one of deriving an intraprediction mode, dividing a block, constructing reference samples andperforming intra prediction may be equally applied to the chroma signal.

The methods may be performed in the encoder and the decoder in the samemanner. For example, in the intra encoding/decoding process, at leastone method of deriving an intra prediction mode, dividing a block,constructing reference samples and performing intra prediction may beapplied in the encoder and the decoder equally. In addition, orders ofapplying the methods may be different in the encoder and the decoder.For example, in performing intra encoding/decoding for the currentblock, an encoder may encode an intra prediction mode determined byperforming at least one intra prediction after constructing referencesamples.

The embodiments of the present invention may be applied according to thesize of at least one of a coding block, a prediction block, a block, anda unit. Here, the size may be defined as the minimum size and/or themaximum size in order to apply the embodiments, and may be defined as afixed size to which the embodiment is applied. In addition, a firstembodiment may be applied in a first size, and a second embodiment maybe applied in a second size. That is, the embodiments may be multiplyapplied according to the size. In addition, the embodiments of thepresent invention may be applied only when the size is equal to orgreater than the minimum size and is equal to or less than the maximumsize. That is, the embodiments may be applied only when the block sizeis in a predetermined range.

For example, only when the size of the encoding/decoding target block isequal to or greater than 8×8, the embodiments may be applied. Forexample, only when the size of the encoding/decoding target block isequal to or greater than 16×16, the embodiments may be applied. Forexample, only when the size of the encoding/decoding target block isequal to or greater than 32×32, the embodiments may be applied. Forexample, only when the size of the encoding/decoding target block isequal to or greater than 64×64, the embodiments may be applied. Forexample, only when the size of the encoding/decoding target block isequal to or greater than 128×128, the embodiments may be applied. Forexample, only when the size of the encoding/decoding target block is4×4, the embodiments may be applied. For example, only when the size ofthe encoding/decoding target block is equal to or less than 8×8, theembodiments may be applied. For example, only when the size of theencoding/decoding target block is equal to or greater than 16×16, theembodiments may be applied. For example, only when the size of theencoding/decoding target block is equal to or greater than 8×8 and isequal to or less than 16×16, the embodiments may be applied. Forexample, only when the size of the encoding/decoding target block isequal to or greater than 16×16 and is equal to or less than 64×64, theembodiments may be applied.

The embodiments of the present invention may be applied according to atemporal layer. An identifier for identifying the temporal layer towhich the embodiment can be applied may be signaled, and the embodimentsmay be applied for the temporal layer specified by the identifier. Here,the identifier may be defined as indicating the minimum layer and/or themaximum layer to which the embodiment can be applied, and may be definedas indicating a particular layer to which the embodiment can be applied.

For example, only when the temporal layer of the current picture is thelowest layer, the embodiments may be applied. For example, only when atemporal layer identifier of the current picture is zero, theembodiments may be applied. For example, only when the temporal layeridentifier of the current picture is equal to or greater than one, theembodiments may be applied. For example, only when the temporal layer ofthe current picture is the highest layer, the embodiments may beapplied.

As described in the embodiment of the present invention, a referencepicture set used in processes of reference picture list construction andreference picture list modification may use at least one of referencepicture lists L0, L1, L2, and L3.

According to the embodiments of the present invention, when a deblockingfilter calculates boundary strength, at least one to at most N motionvectors of the encoding/decoding target block may be used. Here, Nindicates a positive integer equal to or greater than 1 such as 2, 3, 4,etc.

In motion vector prediction, when the motion vector has at least one ofa 16-pixel (16-pel) unit, a 8-pixel (8-pel) unit, a 4-pixel (4-pel)unit, an integer-pixel (integer-pel) unit, a ½-pixel (½-pel) unit, a¼-pixel (¼-pel) unit, a ⅛-pixel (⅛-pel) unit, a 1/16-pixel ( 1/16-pel)unit, a 1/32-pixel ( 1/32-pel) unit, and a 1/64-pixel ( 1/64-pel) unit,the embodiments of the present invention may be applied. In addition, inperforming motion vector prediction, the motion vector may be optionallyused for each pixel unit.

A slice type to which the embodiments of the present invention may bedefined and the embodiments of the present invention may be appliedaccording to the slice type.

For example, when the slice type is a T (Tri-predictive)-slice, aprediction block may be generated by using at least three motionvectors, and may be used as the final prediction block of theencoding/decoding target block by calculating a weighted sum of at leastthree prediction blocks. For example, when the slice type is a Q(Quad-predictive)-slice, a prediction block may be generated by using atleast four motion vectors, and may be used as the final prediction blockof the encoding/decoding target block by calculating a weighted sum ofat least four prediction blocks.

The embodiment of the present invention may be applied to interprediction and motion compensation methods using motion vectorprediction as well as inter prediction and motion compensation methodsusing a skip mode, a merge mode, etc.

The shape of the block to which the embodiments of the present inventionis applied may have a square shape or a non-square shape.

In the above-described embodiments, the methods are described based onthe flowcharts with a series of steps or units, but the presentinvention is not limited to the order of the steps, and rather, somesteps may be performed simultaneously or in different order with othersteps. In addition, it should be appreciated by one of ordinary skill inthe art that the steps in the flowcharts do not exclude each other andthat other steps may be added to the flowcharts or some of the steps maybe deleted from the flowcharts without influencing the scope of thepresent invention.

The embodiments include various aspects of examples. All possiblecombinations for various aspects may not be described, but those skilledin the art will be able to recognize different combinations.Accordingly, the present invention may include all replacements,modifications, and changes within the scope of the claims.

The embodiments of the present invention may be implemented in a form ofprogram instructions, which are executable by various computercomponents, and recorded in a computer-readable recording medium. Thecomputer-readable recording medium may include stand-alone or acombination of program instructions, data files, data structures, etc.The program instructions recorded in the computer-readable recordingmedium may be specially designed and constructed for the presentinvention, or well-known to a person of ordinary skilled in computersoftware technology field. Examples of the computer-readable recordingmedium include magnetic recording media such as hard disks, floppydisks, and magnetic tapes; optical data storage media such as CD-ROMs orDVD-ROMs; magneto-optimum media such as floptical disks; and hardwaredevices, such as read-only memory (ROM), random-access memory (RAM),flash memory, etc., which are particularly structured to store andimplement the program instruction. Examples of the program instructionsinclude not only a mechanical language code formatted by a compiler butalso a high level language code that may be implemented by a computerusing an interpreter. The hardware devices may be configured to beoperated by one or more software modules or vice versa to conduct theprocesses according to the present invention.

Although the present invention has been described in terms of specificitems such as detailed elements as well as the limited embodiments andthe drawings, they are only provided to help more general understandingof the invention, and the present invention is not limited to the aboveembodiments. It will be appreciated by those skilled in the art to whichthe present invention pertains that various modifications and changesmay be made from the above description.

Therefore, the spirit of the present invention shall not be limited tothe above-described embodiments, and the entire scope of the appendedclaims and their equivalents will fall within the scope and spirit ofthe invention.

INDUSTRIAL APPLICABILITY

The present invention may be used in encoding/decoding an image.

1. An image decoding method, comprising: deriving an intra predictionmode of a current block; determining a search range of reference samplesfor an intra prediction of the current block; determining the referencesamples for the intra prediction of the current block among the searchrange of the reference samples; generating a prediction block byperforming the intra prediction for the current block based on the intraprediction mode and the reference samples; and reconstructing thecurrent block based on the prediction block, wherein a predeterminednumber of the reference samples are non-adjacent reference samples thatare apart from each other by a predetermined sample unit among thesearch range, and wherein the predetermined sample unit is determined tobe a half or a quarter of a size of the current block.
 2. The method ofclaim 1, wherein the search range is determined based on the intraprediction mode of the current block and a size of the current block. 3.The method of claim 1, wherein the reference samples are determined byshifting the predetermined sample unit only for a left reference sampleor an upper reference sample of the current block.
 4. An image encodingmethod, comprising: deriving an intra prediction mode of a currentblock; determining a search range of reference samples for an intraprediction of the current block; determining the reference samples forthe intra prediction of the current block among the search range of thereference samples; generating a prediction block by performing the intraprediction for the current block based on the intra prediction mode andthe reference samples; reconstructing the current block based on theprediction block, wherein a predetermined number of the referencesamples are non-adjacent reference samples that are apart from eachother by a predetermined sample unit among the search range, and whereinthe predetermined sample unit is determined to be a half or a quarter ofa size of the current block.
 5. The method of claim 4, wherein thesearch range is determined based on the intra prediction mode of thecurrent block and a size of the current block.
 6. The method of claim 4,wherein the reference samples are determined by shifting thepredetermined sample unit only for a left reference sample or an upperreference sample of the current block.
 7. A non-transitorycomputer-readable storage medium storing a bitstream formed by a methodof encoding a video, the method comprising: deriving an intra predictionmode of a current block; determining a search range of reference samplesfor an intra prediction of the current block; determining the referencesamples for the intra prediction of the current block among the searchrange of the reference samples; generating a prediction block byperforming the intra prediction for the current block based on the intraprediction mode and the reference samples; and reconstructing thecurrent block based on the prediction block, wherein a predeterminednumber of the reference samples are non-adjacent reference samples thatare apart from each other by a predetermined sample unit among thesearch range, and wherein the predetermined sample unit is determined tobe a half or a quarter of a size of the current block.